@@ -565,26 +565,10 @@ function MonitorStream(monitorData) {
565565 console . debug ( `! ${ dateTimeToISOLocal ( new Date ( ) ) } Stream for ID=${ this . id } STOPPING` ) ;
566566 this . statusCmdTimer = clearInterval ( this . statusCmdTimer ) ;
567567 this . streamCmdTimer = clearInterval ( this . streamCmdTimer ) ;
568- this . started = false ;
569568
570569 if ( - 1 !== this . activePlayer . indexOf ( 'zms' ) ) {
571570 // Icon: My current thought is to just tell zms to stop. Don't go to single.
572- if ( 0 && stream . src ) {
573- let src = stream . src ;
574- if ( - 1 === src . indexOf ( 'mode=' ) ) {
575- src += '&mode=single' ;
576- } else {
577- src = src . replace ( / m o d e = j p e g / i, 'mode=single' ) ;
578- }
579-
580- if ( stream . src != src ) {
581- stream . src = '' ;
582- stream . src = src ;
583- }
584- }
585- if ( stream . src ) {
586- this . streamCommand ( CMD_STOP ) ;
587- }
571+ if ( this . started ) this . streamCommand ( CMD_STOP ) ;
588572 } else if ( - 1 !== this . activePlayer . indexOf ( 'go2rtc' ) ) {
589573 if ( ! ( stream . wsState === WebSocket . CLOSED && stream . pcState === WebSocket . CLOSED ) ) {
590574 try {
@@ -620,6 +604,7 @@ function MonitorStream(monitorData) {
620604 } else {
621605 console . log ( "Unknown activePlayer" , this . activePlayer ) ;
622606 }
607+ this . started = false ;
623608 } ;
624609
625610 this . stopMse = function ( ) {
@@ -694,10 +679,10 @@ function MonitorStream(monitorData) {
694679 stream . onload = null ;
695680
696681 // this.stop tells zms to stop streaming, but the process remains. We need to turn the stream into an image.
697- if ( stream . src && ( - 1 !== this . activePlayer . indexOf ( 'zms' ) ) && this . connKey ) {
682+ if ( this . started && ( - 1 !== this . activePlayer . indexOf ( 'zms' ) ) && this . connKey ) {
698683 // Make zms exit, sometimes zms doesn't receive SIGPIPE, so try to send QUIT
699684 this . streamCommand ( CMD_QUIT ) ;
700- stream . src = '' ;
685+ this . connKey = null ;
701686 }
702687 // Kill and stop share a lot of the same code... so just call stop
703688 this . stop ( ) ;
@@ -716,13 +701,11 @@ function MonitorStream(monitorData) {
716701 /* HLS does not have "src", WebRTC and MSE have "src" */
717702 this . element . pause ( ) ;
718703 this . statusCmdTimer = clearInterval ( this . statusCmdTimer ) ;
719- } else {
720- if ( this . element . src ) {
721- this . streamCommand ( CMD_PAUSE ) ;
722- } else {
723- this . element . pause ( ) ;
724- this . statusCmdTimer = clearInterval ( this . statusCmdTimer ) ;
725- }
704+ } else if ( ( - 1 !== this . activePlayer . indexOf ( 'zms' ) ) && this . connKey ) {
705+ this . streamCommand ( CMD_PAUSE ) ;
706+ } else { // janus?
707+ this . element . pause ( ) ;
708+ this . statusCmdTimer = clearInterval ( this . statusCmdTimer ) ;
726709 }
727710 } ;
728711
@@ -745,13 +728,11 @@ function MonitorStream(monitorData) {
745728 }
746729 } ) ;
747730 this . statusCmdTimer = setInterval ( this . statusCmdQuery . bind ( this ) , statusRefreshTimeout ) ;
731+ } else if ( ( - 1 !== this . activePlayer . indexOf ( 'zms' ) ) && this . connKey ) {
732+ this . streamCommand ( CMD_PLAY ) ;
748733 } else {
749- if ( this . element . src ) {
750- this . streamCommand ( CMD_PLAY ) ;
751- } else {
752- this . element . play ( ) ;
753- this . statusCmdTimer = setInterval ( this . statusCmdQuery . bind ( this ) , statusRefreshTimeout ) ;
754- }
734+ this . element . play ( ) ;
735+ this . statusCmdTimer = setInterval ( this . statusCmdQuery . bind ( this ) , statusRefreshTimeout ) ;
755736 }
756737 } ;
757738
@@ -1196,16 +1177,14 @@ function MonitorStream(monitorData) {
11961177 if ( ! this . started ) return ;
11971178 console . error ( respObj . message ) ;
11981179 // Try to reload the image stream.
1199- if ( stream . src ) {
1200- console . log ( 'Reloading stream: ' + stream . src ) ;
1201- // Instead of changing rand, perhaps we should be changing connKey.
1202- let src = ( - 1 != stream . src . indexOf ( 'rand=' ) ) ? stream . src . replace ( / r a n d = \d + / i, 'rand=' + Math . floor ( ( Math . random ( ) * 1000000 ) ) ) : stream . src + '&rand=' + Math . floor ( ( Math . random ( ) * 1000000 ) ) ;
1203- src = src . replace ( / a u t h = \w + / i, 'auth=' + auth_hash ) ;
1204- this . streamCmdParms . connkey = this . statusCmdParms . connkey = this . connKey = this . genConnKey ( ) ;
1205- src = src . replace ( / c o n n k e y = \d + / i, 'connkey=' + this . connKey ) ;
1206- stream . src = '' ;
1207- stream . src = src ;
1208- }
1180+ console . log ( 'Reloading stream: ' + stream . src ) ;
1181+ // Instead of changing rand, perhaps we should be changing connKey.
1182+ let src = ( - 1 != stream . src . indexOf ( 'rand=' ) ) ? stream . src . replace ( / r a n d = \d + / i, 'rand=' + Math . floor ( ( Math . random ( ) * 1000000 ) ) ) : stream . src + '&rand=' + Math . floor ( ( Math . random ( ) * 1000000 ) ) ;
1183+ src = src . replace ( / a u t h = \w + / i, 'auth=' + auth_hash ) ;
1184+ this . streamCmdParms . connkey = this . statusCmdParms . connkey = this . connKey = this . genConnKey ( ) ;
1185+ src = src . replace ( / c o n n k e y = \d + / i, 'connkey=' + this . connKey ) ;
1186+ stream . src = '' ;
1187+ stream . src = src ;
12091188 } // end if Ok or not
12101189 } ; // this.getStreamCmdResponse
12111190
@@ -1375,11 +1354,6 @@ function MonitorStream(monitorData) {
13751354 } else {
13761355 params . command = command ;
13771356 }
1378- /*
1379- if (this.ajaxQueue) {
1380- this.ajaxQueue.abort();
1381- }
1382- */
13831357 this . streamCmdReq ( params ) ;
13841358 } ;
13851359
0 commit comments