Skip to content

Commit

Permalink
Fix camera getting muted when disconnecting from a video room
Browse files Browse the repository at this point in the history
  • Loading branch information
robintown committed Apr 27, 2022
1 parent 7c326f4 commit 1151807
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/vector/jitsi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,14 @@ function joinConference(audioDevice?: string, videoDevice?: string) {
if (isVideoChannel) meetApi.executeCommand("setTileView", true);
});

meetApi.on("readyToClose", () => {
switchVisibleContainers();
meetApi.on("videoConferenceLeft", () => {
notifyHangup();
meetApi = null;
});

meetApi.on("readyToClose", () => {
switchVisibleContainers();
document.getElementById("jitsiContainer").innerHTML = "";
meetApi = null;

if (skipOurWelcomeScreen) {
skipToJitsiSplashScreen();
Expand All @@ -404,8 +406,17 @@ function joinConference(audioDevice?: string, videoDevice?: string) {
});

meetApi.on("videoMuteStatusChanged", ({ muted }) => {
const action = muted ? ElementWidgetActions.MuteVideo : ElementWidgetActions.UnmuteVideo;
widgetApi.transport.send(action, {});
if (muted) {
// Jitsi Meet always sends a "video muted" event directly before
// hanging up, which we need to ignore by padding the timeout here,
// otherwise the React SDK will mistakenly think the user turned off
// their video by hand
setTimeout(() => {
if (meetApi) widgetApi.transport.send(ElementWidgetActions.MuteVideo, {});
}, 200);
} else {
widgetApi.transport.send(ElementWidgetActions.UnmuteVideo, {});
}
});

["videoConferenceJoined", "participantJoined", "participantLeft"].forEach(event => {
Expand Down

0 comments on commit 1151807

Please sign in to comment.