2020-06-19 05:46:00 +02:00
|
|
|
var playerRestartTimer;
|
|
|
|
|
2020-06-18 01:35:47 +02:00
|
|
|
async function getStatus() {
|
|
|
|
const url = "/status";
|
|
|
|
|
|
|
|
try {
|
|
|
|
const response = await fetch(url);
|
|
|
|
const status = await response.json();
|
|
|
|
|
2020-06-19 05:46:00 +02:00
|
|
|
clearTimeout(playerRestartTimer);
|
|
|
|
|
2020-06-18 01:35:47 +02:00
|
|
|
if (!app.isOnline && status.online) {
|
|
|
|
// 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.
|
2020-06-19 05:46:00 +02:00
|
|
|
playerRestartTimer = setTimeout(function () {
|
2020-06-18 01:35:47 +02:00
|
|
|
restartPlayer();
|
2020-06-19 05:46:00 +02:00
|
|
|
}, 3000);
|
2020-06-18 01:35:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
app.streamStatus = status.online
|
|
|
|
? "Stream is online."
|
|
|
|
: "Stream is offline."
|
|
|
|
|
2020-06-26 06:56:43 +02:00
|
|
|
const player = videojs('video');
|
|
|
|
if (app.isOnline) {
|
|
|
|
player.poster('/thumbnail.jpg');
|
|
|
|
} else {
|
|
|
|
// Change this to some kind of offline image.
|
|
|
|
player.poster('/img/logo.png');
|
|
|
|
}
|
|
|
|
|
2020-06-18 01:35:47 +02:00
|
|
|
app.viewerCount = status.viewerCount;
|
|
|
|
app.sessionMaxViewerCount = status.sessionMaxViewerCount;
|
|
|
|
app.overallMaxViewerCount = status.overallMaxViewerCount;
|
|
|
|
app.isOnline = status.online;
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
app.streamStatus = "Stream server is offline."
|
|
|
|
app.viewerCount = 0
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|