Skip to content

Commit

Permalink
Fix camera getting muted when disconnecting from a video room (#21958)
Browse files Browse the repository at this point in the history
  • Loading branch information
robintown committed Apr 29, 2022
1 parent 2c7680b commit b5336c9
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 b5336c9

Please sign in to comment.