Merge branch 'master' of github.com:ZoneMinder/zoneminder

This commit is contained in:
Isaac Connor
2024-05-29 10:10:54 -04:00
2 changed files with 10 additions and 1 deletions

View File

@@ -316,6 +316,7 @@ function MonitorStream(monitorData) {
}
stream.onerror = this.img_onerror.bind(this);
stream.onload = this.img_onload.bind(this);
this.started = true;
}; // this.start
this.stop = function() {
@@ -331,6 +332,7 @@ function MonitorStream(monitorData) {
this.streamCommand(CMD_STOP);
this.statusCmdTimer = clearInterval(this.statusCmdTimer);
this.streamCmdTimer = clearInterval(this.streamCmdTimer);
this.started = false;
};
this.kill = function() {

View File

@@ -1103,12 +1103,19 @@ function changeMonitorStatusPositon() {
// Kick everything off
$j(window).on('load', () => initPage());
//Stop monitors when closing page
document.onvisibilitychange = () => {
if (document.visibilityState === "hidden") {
//Stop monitors when closing or hiding page
for (let i = 0, length = monitorData.length; i < length; i++) {
monitors[i].kill();
}
} else {
//Start monitors when show page
for (let i = 0, length = monitorData.length; i < length; i++) {
if (!monitors[i].started) {
monitors[i].start();
}
}
}
};