diff --git a/public/main.js b/public/main.js index f9b0d25..2c2c645 100644 --- a/public/main.js +++ b/public/main.js @@ -63,6 +63,7 @@ var app = new Vue({ }); let call = this.peer.call(peerId, this.stream); + console.log('Started call', call); call.on('stream', (stream) => this.renderVideo(stream, '#video-'+call.connectionId)); call.on('close', () => { console.log(`[OUT] Call with ${peerId} was closed.`); @@ -187,13 +188,17 @@ var app = new Vue({ }, gotStream: function gotStream(stream) { console.log('gotStream', this.stream, stream); - if (this.stream) { - const oldVideo = this.stream.getTracks().find(track => track.kind === 'video'); - this.stream.removeTrack(oldVideo); - // this.stream.addTrack(stream); - } else { - this.stream = stream; // make stream available to console + if (this.calls && (this.calls.length > 0)) { + this.calls.forEach(call => { + console.log('local streams',call.peerConnection.getLocalStreams()); + call.peerConnection.removeStream(this.stream); + console.log('local streams',call.peerConnection.getLocalStreams()); + console.log('Adding stream', stream) + call.peerConenction.addStream(stream); + console.log('local streams',call.peerConnection.getLocalStreams()); + }); } + this.stream = stream; // make stream available to console document.querySelector('#localVideo').srcObject = stream; // Refresh button list in case labels have become available return navigator.mediaDevices.enumerateDevices();