1
0
Fork 0
mirror of https://api.glitch.com/git/yaswvc synced 2026-01-12 01:38:10 +00:00

👌👰 Checkpoint

./public/main.js:5975361/800
This commit is contained in:
Glitch (peerjs-video) 2020-09-12 20:40:30 +00:00
parent a564d54fee
commit 2c99731d00

View file

@ -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();