Merge pull request #4643 from IgorA100/patch-412820
Fix: More correct processing of the stream after hiding and then displaying the Watch pagepull/4683/head
commit
a13d618946
|
|
@ -6,6 +6,7 @@ function MonitorStream(monitorData) {
|
|||
this.id = monitorData.id;
|
||||
this.name = monitorData.name;
|
||||
this.started = false;
|
||||
this.zmsState = null;
|
||||
this.muted = (currentView == 'watch') ? !!getCookie('zmWatchMuted') : true;
|
||||
this.connKey = monitorData.connKey;
|
||||
this.genConnKey = function() {
|
||||
|
|
@ -1558,6 +1559,13 @@ function MonitorStream(monitorData) {
|
|||
params.command = command;
|
||||
}
|
||||
this.streamCmdReq(params);
|
||||
if (params.command == CMD_PAUSE) {
|
||||
this.zmsState = 'paused';
|
||||
} else if (params.command == CMD_PLAY) {
|
||||
this.zmsState = 'played';
|
||||
} else if (params.command == CMD_STOP || params.command == CMD_QUIT) {
|
||||
this.zmsState = 'stopped';
|
||||
}
|
||||
};
|
||||
|
||||
this.alarmCommand = function(command) {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ class VideoStream extends VideoRTC {
|
|||
*/
|
||||
oninit() {
|
||||
console.debug('stream.oninit');
|
||||
this.visibilityCheck = false;
|
||||
super.oninit();
|
||||
}
|
||||
|
||||
|
|
@ -68,6 +69,11 @@ class VideoStream extends VideoRTC {
|
|||
super.ondisconnect();
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
console.debug('stream.connectedCallback');
|
||||
super.connectedCallback();
|
||||
}
|
||||
|
||||
onopen() {
|
||||
console.debug('stream.onopen');
|
||||
const result = super.onopen();
|
||||
|
|
|
|||
|
|
@ -1382,7 +1382,7 @@ function changePlayer() {
|
|||
// Kick everything off
|
||||
$j( window ).on("load", initPage);
|
||||
|
||||
var prevStateStarted = false;
|
||||
var prevStateStarted = null;
|
||||
document.onvisibilitychange = () => {
|
||||
// Always clear it because the return to visibility might happen before timeout
|
||||
TimerHideShow = clearTimeout(TimerHideShow);
|
||||
|
|
@ -1391,22 +1391,29 @@ document.onvisibilitychange = () => {
|
|||
//Stop monitor when closing or hiding page
|
||||
if (monitorStream) {
|
||||
if (monitorStream.started) {
|
||||
prevStateStarted = 'played';
|
||||
//Stop only if playing or paused.
|
||||
// We might want to continue status updates so that alarm sounds etc still happen
|
||||
monitorStream.stop();
|
||||
if ((monitorStream.zmsState == 'paused') || (monitorStream.element.video && monitorStream.element.video.paused) || monitorStream.element.paused) {
|
||||
prevStateStarted = 'paused';
|
||||
} else {
|
||||
prevStateStarted = 'played';
|
||||
//Stop only if playing (not paused).
|
||||
// We might want to continue status updates so that alarm sounds etc still happen
|
||||
monitorStream.stop();
|
||||
}
|
||||
} else {
|
||||
prevStateStarted = false;
|
||||
prevStateStarted = 'stopped';
|
||||
}
|
||||
}
|
||||
}, 15*1000);
|
||||
} else {
|
||||
//Start monitor when show page
|
||||
if (monitorStream && prevStateStarted == 'played' && !idleTimeoutTriggered) {
|
||||
prevStateStarted = false;
|
||||
prevStateStarted = null;
|
||||
onPlay(); //Set the correct state of the player buttons.
|
||||
monitorStream.start(monitorStream.currentChannelStream);
|
||||
monitorsSetScale(monitorId);
|
||||
//} else if (prevStateStarted != 'paused') {
|
||||
} else if (monitorStream && monitorStream.element && ((monitorStream.zmsState == 'paused') || (monitorStream.element.video && monitorStream.element.video.paused) || monitorStream.element.paused)) {
|
||||
prevStateStarted = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue