Fix to add special screen sharing

This commit is contained in:
Gregoire Parant 2020-06-08 09:36:07 +02:00 committed by David Négrier
parent 209057e3fc
commit 3e2c5049f2
2 changed files with 8 additions and 18 deletions

View File

@ -298,7 +298,11 @@ export class MediaManager {
<video id="${userId}" autoplay></video> <video id="${userId}" autoplay></video>
</div> </div>
`); `);
this.remoteVideo.set(userId, document.getElementById(userId)); let activeHTMLVideoElement : HTMLElement|null = document.getElementById(userId);
if(!activeHTMLVideoElement){
return;
}
this.remoteVideo.set(userId, (activeHTMLVideoElement as HTMLVideoElement));
} }
/** /**

View File

@ -122,9 +122,11 @@ export class SimplePeer {
} }
let screenSharing : boolean = name !== undefined && name.indexOf("screenSharing") > -1; let screenSharing : boolean = name !== undefined && name.indexOf("screenSharing") > -1;
mediaManager.removeActiveVideo(user.userId);
if(!screenSharing) { if(!screenSharing) {
mediaManager.removeActiveVideo(user.userId);
mediaManager.addActiveVideo(user.userId, name); mediaManager.addActiveVideo(user.userId, name);
}else{
mediaManager.addScreenSharingActiveVideo(user.userId, name);
} }
const peer : SimplePeerNamespace.Instance = new Peer({ const peer : SimplePeerNamespace.Instance = new Peer({
@ -151,22 +153,6 @@ export class SimplePeer {
}); });
peer.on('stream', (stream: MediaStream) => { peer.on('stream', (stream: MediaStream) => {
if(screenSharing){
//add stream video on
return;
}
let videoActive = false;
let microphoneActive = false;
stream.getTracks().forEach((track : MediaStreamTrack) => {
if(track.kind === "audio"){
microphoneActive = true;
}
if(track.kind === "video"){
videoActive = true;
}
});
this.stream(user.userId, stream); this.stream(user.userId, stream);
}); });