Fix to add special screen sharing
This commit is contained in:
parent
747ed5b733
commit
81c030392f
2 changed files with 14 additions and 30 deletions
|
@ -11,7 +11,7 @@ interface MediaServiceInterface extends MediaDevices{
|
|||
}
|
||||
export class MediaManager {
|
||||
// @ts-ignore
|
||||
remoteVideo: Map<string, any> = new Map<string, any>();
|
||||
remoteVideo: Map<string, HTMLVideoElement> = new Map<string, HTMLVideoElement>();
|
||||
|
||||
localStream: MediaStream|null = null;
|
||||
localScreenCapture: MediaStream|null = null;
|
||||
|
@ -228,7 +228,11 @@ export class MediaManager {
|
|||
<video id="${userId}" autoplay></video>
|
||||
</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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -245,7 +249,11 @@ export class MediaManager {
|
|||
<video id="${userId}" autoplay></video>
|
||||
</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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -105,9 +105,11 @@ export class SimplePeer {
|
|||
}
|
||||
|
||||
let screenSharing : boolean = name !== undefined && name.indexOf("screenSharing") > -1;
|
||||
this.MediaManager.removeActiveVideo(user.userId);
|
||||
if(!screenSharing) {
|
||||
this.MediaManager.removeActiveVideo(user.userId);
|
||||
this.MediaManager.addActiveVideo(user.userId, name);
|
||||
}else{
|
||||
this.MediaManager.addScreenSharingActiveVideo(user.userId, name);
|
||||
}
|
||||
|
||||
let peer : SimplePeerNamespace.Instance = new Peer({
|
||||
|
@ -134,32 +136,6 @@ export class SimplePeer {
|
|||
});
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
if(microphoneActive){
|
||||
this.MediaManager.enabledMicrophoneByUserId(user.userId);
|
||||
}else{
|
||||
this.MediaManager.disabledMicrophoneByUserId(user.userId);
|
||||
}
|
||||
|
||||
if(videoActive){
|
||||
this.MediaManager.enabledVideoByUserId(user.userId);
|
||||
}else{
|
||||
this.MediaManager.disabledVideoByUserId(user.userId);
|
||||
}
|
||||
this.stream(user.userId, stream);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue