Fix connection indicator
This commit is contained in:
parent
5ad8a69c4c
commit
28ef6a5526
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,6 @@
|
|||
"{{$value}}",
|
||||
{{end}}
|
||||
]
|
||||
let player = initViewerPage(stream, /*stunServers,*/ viewersCounterRefreshPeriod, {{.Cfg.PlayerPoster}})
|
||||
initViewerPage(stream, /*stunServers,*/ viewersCounterRefreshPeriod, {{.Cfg.PlayerPoster}})
|
||||
</script>
|
||||
{{end}}
|
||||
|
|
Loading…
Reference in New Issue