Properly release local media devices when user turns off their cam

ipad-testing
Noah 2023-07-08 12:08:46 -07:00
parent 3a334a8d68
commit f4568b9087
1 changed files with 12 additions and 6 deletions

View File

@ -1376,12 +1376,6 @@ const app = Vue.createApp({
// Stop broadcasting.
stopVideo() {
this.webcam.elem.srcObject = null;
this.webcam.stream = null;
this.webcam.active = false;
this.webcam.muted = false;
this.whoTab = "online";
// Close all WebRTC sessions.
for (username of Object.keys(this.WebRTC.pc)) {
this.closeVideo(username, "answerer");
@ -1390,6 +1384,18 @@ const app = Vue.createApp({
// Hang up on mutual cameras.
this.unMutualVideo();
// Close the local camera devices completely.
this.webcam.stream.getTracks().forEach(track => {
track.stop();
});
// Reset all front-end state.
this.webcam.elem.srcObject = null;
this.webcam.stream = null;
this.webcam.active = false;
this.webcam.muted = false;
this.whoTab = "online";
// Tell backend our camera state.
this.sendMe();
},