2020-06-18 00:02:50 +02:00
|
|
|
// style hackings
|
|
|
|
window.VIDEOJS_NO_DYNAMIC_STYLE = true;
|
|
|
|
|
|
|
|
// Wait until the player is setup before we start polling status
|
2020-06-18 02:13:55 +02:00
|
|
|
const player = videojs('video');
|
|
|
|
|
|
|
|
player.on('ready', function () {
|
2020-06-18 02:48:33 +02:00
|
|
|
console.log('Player ready.')
|
2020-06-18 00:02:50 +02:00
|
|
|
getStatus();
|
|
|
|
setInterval(getStatus, 5000);
|
|
|
|
setupPlayerEventHandlers();
|
2020-06-18 02:13:55 +02:00
|
|
|
})
|
2020-06-18 00:02:50 +02:00
|
|
|
|
|
|
|
function setupPlayerEventHandlers() {
|
|
|
|
const player = videojs('video');
|
|
|
|
|
|
|
|
player.on('error', function (e) {
|
2020-06-18 02:48:33 +02:00
|
|
|
console.log("Player error: ", e);
|
2020-06-18 00:02:50 +02:00
|
|
|
})
|
|
|
|
|
2020-06-18 02:48:33 +02:00
|
|
|
// player.on('loadeddata', function (e) {
|
|
|
|
// console.log("loadeddata");
|
|
|
|
// })
|
2020-06-18 00:02:50 +02:00
|
|
|
|
2020-06-18 02:48:33 +02:00
|
|
|
// player.on('ended', function (e) {
|
|
|
|
// console.log("ended");
|
|
|
|
// })
|
|
|
|
//
|
2020-06-18 00:02:50 +02:00
|
|
|
// player.on('abort', function (e) {
|
|
|
|
// console.log("abort");
|
|
|
|
// })
|
2020-06-18 02:48:33 +02:00
|
|
|
//
|
2020-06-18 00:02:50 +02:00
|
|
|
// player.on('durationchange', function (e) {
|
|
|
|
// console.log("durationchange");
|
|
|
|
// })
|
2020-06-18 02:48:33 +02:00
|
|
|
//
|
2020-06-18 00:02:50 +02:00
|
|
|
// player.on('stalled', function (e) {
|
|
|
|
// console.log("stalled");
|
|
|
|
// })
|
2020-06-18 02:48:33 +02:00
|
|
|
//
|
|
|
|
// player.on('playing', function (e) {
|
|
|
|
// // console.log("playing");
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// player.on('waiting', function (e) {
|
|
|
|
// // console.log("waiting");
|
|
|
|
// })
|
2020-06-18 00:02:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function restartPlayer() {
|
|
|
|
try {
|
|
|
|
const player = videojs('video');
|
|
|
|
|
|
|
|
player.src(player.src()); // Reload the same video
|
|
|
|
player.load();
|
|
|
|
player.play();
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|