From c8bc0661b11c5a1105057215640d1c06f68dfa24 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 8 Jan 2022 12:14:28 -0500 Subject: [PATCH] Have to clear src before resetting or some browsers won't load the new image --- web/js/MonitorStream.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/web/js/MonitorStream.js b/web/js/MonitorStream.js index 5e652eb3d..ef4d6db41 100644 --- a/web/js/MonitorStream.js +++ b/web/js/MonitorStream.js @@ -2,6 +2,8 @@ function MonitorStream(monitorData) { this.id = monitorData.id; this.connKey = monitorData.connKey; + this.auth_relay = auth_relay; + this.auth_hash = auth_hash; this.url = monitorData.url; this.url_to_zms = monitorData.url_to_zms; this.width = monitorData.width; @@ -206,36 +208,38 @@ function MonitorStream(monitorData) { var newAlarm = ( isAlarmed && !wasAlarmed ); var oldAlarm = ( !isAlarmed && wasAlarmed ); - if ( newAlarm ) { - if ( false && SOUND_ON_ALARM ) { + if (newAlarm) { + if (false && SOUND_ON_ALARM) { // Enable the alarm sound $j('#alarmSound').removeClass('hidden'); } - if ( (typeof POPUP_ON_ALARM !== 'undefined') && POPUP_ON_ALARM ) { + if ((typeof POPUP_ON_ALARM !== 'undefined') && POPUP_ON_ALARM) { windowToFront(); } } - if ( false && SOUND_ON_ALARM ) { + if (false && SOUND_ON_ALARM) { if ( oldAlarm ) { // Disable alarm sound $j('#alarmSound').addClass('hidden'); } } - if ( this.status.auth ) { - if ( this.status.auth != auth_hash ) { + if (this.status.auth) { + if (this.status.auth != auth_hash) { // Try to reload the image stream. - if ( stream ) { - stream.src = stream.src.replace(/auth=\w+/i, 'auth='+this.status.auth); + if (stream) { + const oldsrc = stream.src; + stream.src = ''; + stream.src = oldsrc.replace(/auth=\w+/i, 'auth='+this.status.auth); } - console.log("Changed auth from " + auth_hash + " to " + this.status.auth); - auth_hash = this.status.auth; + console.log("Changed auth from " + this.auth_hash + " to " + this.status.auth); + this.auth_hash = this.status.auth; } } // end if have a new auth hash } // end if has state } else { console.error(respObj.message); // Try to reload the image stream. - if ( stream ) { + if (stream) { if ( stream.src ) { console.log('Reloading stream: ' + stream.src); src = stream.src.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) ));