From 2c99731d00f0c6e5e9ac5d744e32690dbe9b2170 Mon Sep 17 00:00:00 2001 From: "Glitch (peerjs-video)" Date: Sat, 12 Sep 2020 20:40:30 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=F0=9F=91=B0=20Checkpoint=20./publi?= =?UTF-8?q?c/main.js:5975361/800?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/main.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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();