Fix errors on Firefox
This commit is contained in:
@@ -12,6 +12,7 @@ async function setupApp() {
|
|||||||
messages: [],
|
messages: [],
|
||||||
description: "",
|
description: "",
|
||||||
title: "",
|
title: "",
|
||||||
|
isOnline: false,
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
messages: {
|
messages: {
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ const player = videojs('video', null, function () {
|
|||||||
getStatus();
|
getStatus();
|
||||||
setInterval(getStatus, 5000);
|
setInterval(getStatus, 5000);
|
||||||
setupPlayerEventHandlers();
|
setupPlayerEventHandlers();
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
player.ready(function () {
|
player.ready(function () {
|
||||||
console.log('Player ready.')
|
console.log('Player ready.')
|
||||||
|
player.reset();
|
||||||
player.src({ type: 'application/x-mpegURL', src: streamURL });
|
player.src({ type: 'application/x-mpegURL', src: streamURL });
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -44,9 +44,9 @@ function setupPlayerEventHandlers() {
|
|||||||
// console.log("stalled");
|
// console.log("stalled");
|
||||||
// })
|
// })
|
||||||
//
|
//
|
||||||
// player.on('playing', function (e) {
|
player.on('playing', function (e) {
|
||||||
// // console.log("playing");
|
clearTimeout(playerRestartTimer);
|
||||||
// })
|
})
|
||||||
//
|
//
|
||||||
// player.on('waiting', function (e) {
|
// player.on('waiting', function (e) {
|
||||||
// // console.log("waiting");
|
// // console.log("waiting");
|
||||||
@@ -55,8 +55,9 @@ function setupPlayerEventHandlers() {
|
|||||||
|
|
||||||
function restartPlayer() {
|
function restartPlayer() {
|
||||||
try {
|
try {
|
||||||
|
console.log('restarting')
|
||||||
const player = videojs('video');
|
const player = videojs('video');
|
||||||
|
player.pause();
|
||||||
player.src(player.src()); // Reload the same video
|
player.src(player.src()); // Reload the same video
|
||||||
player.load();
|
player.load();
|
||||||
player.play();
|
player.play();
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
var playerRestartTimer;
|
||||||
|
|
||||||
async function getStatus() {
|
async function getStatus() {
|
||||||
const url = "/status";
|
const url = "/status";
|
||||||
|
|
||||||
@@ -5,13 +7,14 @@ async function getStatus() {
|
|||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
const status = await response.json();
|
const status = await response.json();
|
||||||
|
|
||||||
|
clearTimeout(playerRestartTimer);
|
||||||
|
|
||||||
if (!app.isOnline && status.online) {
|
if (!app.isOnline && status.online) {
|
||||||
// The stream was offline, but now it's online. Force start of playback after an arbitrary
|
// The stream was offline, but now it's online. Force start of playback after an arbitrary
|
||||||
// delay to make sure the stream has actual data ready to go.
|
// delay to make sure the stream has actual data ready to go.
|
||||||
setTimeout(function () {
|
playerRestartTimer = setTimeout(function () {
|
||||||
restartPlayer();
|
restartPlayer();
|
||||||
}, 3000)
|
}, 3000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.streamStatus = status.online
|
app.streamStatus = status.online
|
||||||
|
|||||||
Reference in New Issue
Block a user