Skip to content

Commit a3269e6

Browse files
Merge branch 'master' of github.com:ZoneMinder/zoneminder
2 parents 50454f2 + 110637d commit a3269e6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

web/skins/classic/views/js/watch.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,19 +1439,27 @@ function monitorsSetScale(id=null) {
14391439
// Kick everything off
14401440
$j( window ).on("load", initPage);
14411441

1442+
var prevStateStarted = false;
14421443
document.onvisibilitychange = () => {
14431444
// Always clear it because the return to visibility might happen before timeout
14441445
TimerHideShow = clearTimeout(TimerHideShow);
14451446
if (document.visibilityState === "hidden") {
14461447
TimerHideShow = setTimeout(function() {
14471448
//Stop monitor when closing or hiding page
14481449
if (monitorStream) {
1449-
monitorStream.kill();
1450+
if (monitorStream.started) {
1451+
prevStateStarted = 'played';
1452+
//Stop only if playing or paused.
1453+
monitorStream.kill();
1454+
} else {
1455+
prevStateStarted = false;
1456+
}
14501457
}
14511458
}, 15*1000);
14521459
} else {
14531460
//Start monitor when show page
1454-
if (monitorStream && !monitorStream.started && (idle<ZM_WEB_VIEWING_TIMEOUT)) {
1461+
if (monitorStream && prevStateStarted == 'played' && (idle<ZM_WEB_VIEWING_TIMEOUT)) {
1462+
onPlay(); //Set the correct state of the player buttons.
14551463
monitorStream.start();
14561464
}
14571465
}

0 commit comments

Comments
 (0)