Merge branch 'develop' into windows-focus-blur-camera

# Conflicts:
#	front/src/WebRtc/MediaManager.ts
This commit is contained in:
Gregoire Parant 2020-11-10 15:27:22 +01:00
commit 8412575c40

View File

@ -44,6 +44,8 @@ export class MediaManager {
private lastUpdateScene : Date = new Date(); private lastUpdateScene : Date = new Date();
private setTimeOutlastUpdateScene? : NodeJS.Timeout; private setTimeOutlastUpdateScene? : NodeJS.Timeout;
private hasCamera = true;
constructor() { constructor() {
this.myCamVideo = this.getElementByIdOrFail<HTMLVideoElement>('myCamVideo'); this.myCamVideo = this.getElementByIdOrFail<HTMLVideoElement>('myCamVideo');
@ -177,7 +179,6 @@ export class MediaManager {
public async disableCamera() { public async disableCamera() {
this.disableCameraStyle(); this.disableCameraStyle();
this.stopCamera();
if (this.constraintsMedia.audio !== false) { if (this.constraintsMedia.audio !== false) {
const stream = await this.getCamera(); const stream = await this.getCamera();
@ -238,6 +239,7 @@ export class MediaManager {
this.cinemaBtn.classList.add("disabled"); this.cinemaBtn.classList.add("disabled");
this.constraintsMedia.video = false; this.constraintsMedia.video = false;
this.myCamVideo.srcObject = null; this.myCamVideo.srcObject = null;
this.stopCamera();
} }
private enableMicrophoneStyle(){ private enableMicrophoneStyle(){
@ -333,24 +335,33 @@ export class MediaManager {
} }
} }
try { return this.getLocalStream().catch(() => {
const stream = await navigator.mediaDevices.getUserMedia(this.constraintsMedia); console.info('Error get camera, trying with video option at null');
this.disableCameraStyle();
return this.getLocalStream().then((stream : MediaStream) => {
this.hasCamera = false;
return stream;
}).catch((err) => {
console.info("error get media ", this.constraintsMedia.video, this.constraintsMedia.audio, err);
throw err;
});
});
//TODO resize remote cam
/*console.log(this.localStream.getTracks());
let videoMediaStreamTrack = this.localStream.getTracks().find((media : MediaStreamTrack) => media.kind === "video");
let {width, height} = videoMediaStreamTrack.getSettings();
console.info(`${width}x${height}`); // 6*/
}
private getLocalStream() : Promise<MediaStream> {
return navigator.mediaDevices.getUserMedia(this.constraintsMedia).then((stream : MediaStream) => {
this.localStream = stream; this.localStream = stream;
this.myCamVideo.srcObject = this.localStream; this.myCamVideo.srcObject = this.localStream;
return stream; return stream;
}).catch((err: Error) => {
//TODO resize remote cam
/*console.log(this.localStream.getTracks());
let videoMediaStreamTrack = this.localStream.getTracks().find((media : MediaStreamTrack) => media.kind === "video");
let {width, height} = videoMediaStreamTrack.getSettings();
console.info(`${width}x${height}`); // 6*/
} catch (err) {
console.info("error get media ", this.constraintsMedia.video, this.constraintsMedia.audio, err);
this.localStream = null;
throw err; throw err;
} });
} }
/** /**