Camera was not properly closed in EnableCameraScene
This commit is contained in:
parent
4d90d4b50b
commit
c739037bc4
2 changed files with 28 additions and 11 deletions
|
@ -266,6 +266,9 @@ export class EnableCameraScene extends Phaser.Scene {
|
|||
this.soundMeter.stop();
|
||||
window.removeEventListener('resize', this.repositionCallback);
|
||||
|
||||
mediaManager.stopCamera();
|
||||
mediaManager.stopMicrophone();
|
||||
|
||||
// Do we have a start URL in the address bar? If so, let's redirect to this address
|
||||
const instanceAndMapUrl = this.findMapUrl();
|
||||
if (instanceAndMapUrl !== null) {
|
||||
|
|
|
@ -127,7 +127,7 @@ export class MediaManager {
|
|||
}
|
||||
}
|
||||
|
||||
showGameOverlay(){
|
||||
public showGameOverlay(){
|
||||
const gameOverlay = this.getElementByIdOrFail('game-overlay');
|
||||
gameOverlay.classList.add('active');
|
||||
}
|
||||
|
@ -148,11 +148,7 @@ export class MediaManager {
|
|||
this.cinemaBtn.classList.add("disabled");
|
||||
this.constraintsMedia.video = false;
|
||||
this.myCamVideo.srcObject = null;
|
||||
if (this.localStream) {
|
||||
this.localStream.getVideoTracks().forEach((MediaStreamTrack: MediaStreamTrack) => {
|
||||
MediaStreamTrack.stop();
|
||||
});
|
||||
}
|
||||
this.stopCamera();
|
||||
this.getCamera().then((stream) => {
|
||||
this.triggerUpdatedLocalStreamCallbacks(stream);
|
||||
});
|
||||
|
@ -173,11 +169,7 @@ export class MediaManager {
|
|||
this.microphone.style.display = "none";
|
||||
this.microphoneBtn.classList.add("disabled");
|
||||
this.constraintsMedia.audio = false;
|
||||
if(this.localStream) {
|
||||
this.localStream.getAudioTracks().forEach((MediaStreamTrack: MediaStreamTrack) => {
|
||||
MediaStreamTrack.stop();
|
||||
});
|
||||
}
|
||||
this.stopMicrophone();
|
||||
this.getCamera().then((stream) => {
|
||||
this.triggerUpdatedLocalStreamCallbacks(stream);
|
||||
});
|
||||
|
@ -287,6 +279,28 @@ export class MediaManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the camera from filming
|
||||
*/
|
||||
public stopCamera(): void {
|
||||
if (this.localStream) {
|
||||
for (const track of this.localStream.getVideoTracks()) {
|
||||
track.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the microphone from listening
|
||||
*/
|
||||
public stopMicrophone(): void {
|
||||
if (this.localStream) {
|
||||
for (const track of this.localStream.getAudioTracks()) {
|
||||
track.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setCamera(id: string): Promise<MediaStream> {
|
||||
let video = this.constraintsMedia.video;
|
||||
if (typeof(video) === 'boolean' || video === undefined) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue