reload stream after error

This commit is contained in:
Isaac Connor 2016-04-19 12:02:58 -04:00
parent e255fcc603
commit b2d02a64f4
1 changed files with 5 additions and 1 deletions

View File

@ -35,6 +35,7 @@ function Monitor( index, id, connKey )
if ( this.streamCmdTimer ) if ( this.streamCmdTimer )
this.streamCmdTimer = clearTimeout( this.streamCmdTimer ); this.streamCmdTimer = clearTimeout( this.streamCmdTimer );
var stream = document.getElementById( "liveStream"+this.id );
if ( respObj.result == 'Ok' ) if ( respObj.result == 'Ok' )
{ {
this.status = respObj.status; this.status = respObj.status;
@ -57,7 +58,6 @@ function Monitor( index, id, connKey )
this.setStateClass( $('monitor'+this.index), stateClass ); this.setStateClass( $('monitor'+this.index), stateClass );
/*Stream could be an applet so can't use moo tools*/ /*Stream could be an applet so can't use moo tools*/
var stream = document.getElementById( "liveStream"+this.id );
stream.className = stateClass; stream.className = stateClass;
var isAlarmed = ( this.alarmState == STATE_ALARM || this.alarmState == STATE_ALERT ); var isAlarmed = ( this.alarmState == STATE_ALARM || this.alarmState == STATE_ALERT );
@ -90,6 +90,10 @@ function Monitor( index, id, connKey )
else else
{ {
console.error( respObj.message ); console.error( respObj.message );
// Try to reload the image stream.
if ( stream )
stream.src = stream.src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) ));
} }
var streamCmdTimeout = statusRefreshTimeout; var streamCmdTimeout = statusRefreshTimeout;
if ( this.alarmState == STATE_ALARM || this.alarmState == STATE_ALERT ) if ( this.alarmState == STATE_ALARM || this.alarmState == STATE_ALERT )