@@ -54,8 +54,10 @@ Stream.prototype.createPeerConnection = function() {
5454 this . peerConnection . ontrack = ( event ) => {
5555 console . log ( "[stream] remote stream added:" , event . streams [ 0 ] ) ;
5656 let remoteVideoElement = document . getElementById ( 'stream' ) ;
57- remoteVideoElement . srcObject = event . streams [ 0 ] ;
58- remoteVideoElement . play ( ) ;
57+ if ( remoteVideoElement . paused ) {
58+ remoteVideoElement . srcObject = event . streams [ 0 ] ;
59+ remoteVideoElement . play ( ) ;
60+ }
5961 }
6062
6163 this . peerConnection . onremovestream = ( ) => console . log ( '[stream] remove' ) ;
@@ -75,7 +77,7 @@ Stream.prototype.offer = function() {
7577 }
7678 } ;
7779 this . websocket . send ( JSON . stringify ( command ) ) ;
78- console . log ( "[stream] offer(), command=" + JSON . stringify ( command ) ) ;
80+ console . debug ( "[stream] offer(), command=" + JSON . stringify ( command ) ) ;
7981}
8082
8183Stream . prototype . open = function ( ) {
@@ -88,7 +90,7 @@ Stream.prototype.addIceCandidates = function () {
8890 this . iceCandidates . forEach ( ( candidate ) => {
8991 this . peerConnection . addIceCandidate ( candidate ,
9092 function ( ) {
91- console . log ( "[stream] IceCandidate added: " + JSON . stringify ( candidate ) ) ;
93+ console . debug ( "[stream] IceCandidate added: " + JSON . stringify ( candidate ) ) ;
9294 } ,
9395 function ( error ) {
9496 console . error ( "[stream] addIceCandidate error: " + error ) ;
@@ -103,7 +105,7 @@ Stream.prototype.message = function(event) {
103105 var msg = JSON . parse ( event . data ) ;
104106 var what = msg . what ;
105107 var data = msg . data ;
106- console . log ( "[stream] message =" + what ) ;
108+ console . debug ( "[stream] message =" + what ) ;
107109
108110 switch ( what ) {
109111 case "offer" :
@@ -158,15 +160,15 @@ Stream.prototype.message = function(event) {
158160
159161
160162Stream . prototype . _onRemoteSdpSuccess = function ( ) {
161- console . log ( '[stream] onRemoteSdpSucces()' ) ;
163+ console . debug ( '[stream] onRemoteSdpSucces()' ) ;
162164 this . remoteDesc = true ;
163165 this . peerConnection . createAnswer ( ( sessionDescription ) => {
164166 this . peerConnection . setLocalDescription ( sessionDescription ) ;
165167 let request = JSON . stringify ( {
166168 what : "answer" ,
167169 data : JSON . stringify ( sessionDescription )
168170 } ) ;
169- console . log ( '[stream] sdp success' , request ) ;
171+ console . debug ( '[stream] sdp success' , request ) ;
170172
171173 this . websocket . send ( request ) ;
172174
0 commit comments