Fix video call
This commit is contained in:
@@ -54,32 +54,58 @@ export class MediaManager {
|
||||
this.cinemaClose.style.display = "none";
|
||||
this.cinema.style.display = "block";
|
||||
this.constraintsMedia.video = true;
|
||||
this.localStream = null;
|
||||
this.myCamVideo.srcObject = null;
|
||||
this.getCamera();
|
||||
}
|
||||
|
||||
disabledCamera() {
|
||||
this.cinemaClose.style.display = "block";
|
||||
this.cinema.style.display = "none";
|
||||
this.constraintsMedia.video = false;
|
||||
|
||||
this.myCamVideo.pause();
|
||||
if(this.localStream) {
|
||||
this.localStream.getTracks().forEach((MediaStreamTrack: MediaStreamTrack) => {
|
||||
if (MediaStreamTrack.kind === "video") {
|
||||
MediaStreamTrack.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
this.localStream = null;
|
||||
this.myCamVideo.srcObject = null;
|
||||
this.getCamera();
|
||||
}
|
||||
|
||||
enabledMicrophone() {
|
||||
this.microphoneClose.style.display = "none";
|
||||
this.microphone.style.display = "block";
|
||||
this.constraintsMedia.audio = true;
|
||||
this.getCamera();
|
||||
}
|
||||
|
||||
disabledMicrophone() {
|
||||
this.microphoneClose.style.display = "block";
|
||||
this.microphone.style.display = "none";
|
||||
this.constraintsMedia.audio = false;
|
||||
if(this.localStream) {
|
||||
this.localStream.getTracks().forEach((MediaStreamTrack: MediaStreamTrack) => {
|
||||
if (MediaStreamTrack.kind === "audio") {
|
||||
MediaStreamTrack.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
this.getCamera();
|
||||
}
|
||||
|
||||
//get camera
|
||||
getCamera() {
|
||||
this.getCameraPromise = navigator.mediaDevices.getUserMedia(this.constraintsMedia)
|
||||
.then((stream: MediaStream) => {
|
||||
console.log("constraintsMedia", stream);
|
||||
this.localStream = stream;
|
||||
this.myCamVideo.srcObject = this.localStream;
|
||||
this.myCamVideo.play();
|
||||
}).catch((err) => {
|
||||
console.error(err);
|
||||
this.localStream = null;
|
||||
|
||||
Reference in New Issue
Block a user