From 0bfed3356a378f7151e4a5615982d233380b6c9e Mon Sep 17 00:00:00 2001 From: IgorA100 Date: Thu, 13 Feb 2025 11:49:03 +0300 Subject: [PATCH] Fix: Start/Stop when showing/hiding page (Update watch.js) When hiding a page: Remember the current state of the stream. If the stream was previously stopped - do nothing When displaying a page: Do not start playback if the stream was stopped before hiding the page. You cannot use "monitorStream.started", because when the stream is stopped it will always be "false" --- web/skins/classic/views/js/watch.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/web/skins/classic/views/js/watch.js b/web/skins/classic/views/js/watch.js index 12a75e3d7..7f0d9d313 100644 --- a/web/skins/classic/views/js/watch.js +++ b/web/skins/classic/views/js/watch.js @@ -1439,6 +1439,7 @@ function monitorsSetScale(id=null) { // Kick everything off $j( window ).on("load", initPage); +var prevStateStarted = false; document.onvisibilitychange = () => { // Always clear it because the return to visibility might happen before timeout TimerHideShow = clearTimeout(TimerHideShow); @@ -1446,12 +1447,19 @@ document.onvisibilitychange = () => { TimerHideShow = setTimeout(function() { //Stop monitor when closing or hiding page if (monitorStream) { - monitorStream.kill(); + if (monitorStream.started) { + prevStateStarted = 'played'; + //Stop only if playing or paused. + monitorStream.kill(); + } else { + prevStateStarted = false; + } } }, 15*1000); } else { //Start monitor when show page - if (monitorStream && !monitorStream.started && (idle