From 28ef6a5526dc6abfea503a8242b822de71e212c4 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 9 Nov 2020 16:48:05 +0100 Subject: [PATCH] Fix connection indicator --- web/static/js/ovenplayer.js | 15 ++++++++------- web/template/player.html | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/web/static/js/ovenplayer.js b/web/static/js/ovenplayer.js index 6b12cc9..816e93a 100644 --- a/web/static/js/ovenplayer.js +++ b/web/static/js/ovenplayer.js @@ -52,23 +52,26 @@ export function initViewerPage(stream, viewersCounterRefreshPeriod, posterUrl) { } ] }); - player.on("stateChanged", function (prevstate, newstate) { - if (newstate === "loading") { + player.on("stateChanged", function (data) { + if (data.newstate === "loading") { document.getElementById("connectionIndicator").style.fill = '#ffc107' } - if (newstate === "ready" || newstate === "play") { + if (data.newstate === "playing") { document.getElementById("connectionIndicator").style.fill = '#28a745' } + if (data.newstate === "idle") { + document.getElementById("connectionIndicator").style.fill = '#dc3545' + } }) player.on("error", function (error) { document.getElementById("connectionIndicator").style.fill = '#dc3545' if (error.code === 501 || error.code === 406) { // Clear messages const errorMsg = document.getElementsByClassName("op-message-text")[0] - //errorMsg.textContent = "" + errorMsg.textContent = "" const warningIcon = document.getElementsByClassName("op-message-icon")[0] - //warningIcon.textContent = "" + warningIcon.textContent = "" // Reload in 30s setTimeout(function () { @@ -99,6 +102,4 @@ export function initViewerPage(stream, viewersCounterRefreshPeriod, posterUrl) { break; } }); - - return player; } diff --git a/web/template/player.html b/web/template/player.html index a585d2f..8e7b145 100644 --- a/web/template/player.html +++ b/web/template/player.html @@ -50,6 +50,6 @@ "{{$value}}", {{end}} ] - let player = initViewerPage(stream, /*stunServers,*/ viewersCounterRefreshPeriod, {{.Cfg.PlayerPoster}}) + initViewerPage(stream, /*stunServers,*/ viewersCounterRefreshPeriod, {{.Cfg.PlayerPoster}}) {{end}}