fix (external-api): fix notify video mute changed when presenting

- small refactor to trigger `notifyVideoMutedStatusChanged` correctly when participant is presenting
This commit is contained in:
hmuresan 2021-05-04 15:57:34 +03:00 committed by Horatiu Muresan
parent 428c3cef38
commit b998d80ee3
3 changed files with 26 additions and 10 deletions

View File

@ -739,7 +739,7 @@ export default {
}
if (!tracks.find(t => t.isVideoTrack())) {
this.setVideoMuteStatus(true);
this.setVideoMuteStatus();
}
if (config.iAmRecorder) {
@ -993,7 +993,7 @@ export default {
// This will only modify base/media.video.muted which is then synced
// up with the track at the end of local tracks initialization.
muteLocalVideo(mute);
this.setVideoMuteStatus(mute);
this.setVideoMuteStatus();
return;
} else if (this.isLocalVideoMuted() === mute) {
@ -1402,7 +1402,7 @@ export default {
.then(() => {
this.localVideo = newTrack;
this._setSharingScreen(newTrack);
this.setVideoMuteStatus(this.isLocalVideoMuted());
this.setVideoMuteStatus();
})
.then(resolve)
.catch(error => {
@ -1821,7 +1821,7 @@ export default {
try {
await this.localVideo.setEffect(effect);
APP.store.dispatch(setVideoMuted(mute, MEDIA_TYPE.PRESENTER));
this.setVideoMuteStatus(mute);
this.setVideoMuteStatus();
} catch (err) {
logger.error('Failed to apply the Presenter effect', err);
}
@ -2303,7 +2303,7 @@ export default {
return this._createPresenterStreamEffect(height, cameraDeviceId)
.then(effect => this.localVideo.setEffect(effect))
.then(() => {
this.setVideoMuteStatus(false);
this.setVideoMuteStatus();
logger.log('Switched local video device while screen sharing and the video is unmuted');
this._updateVideoDeviceId();
})
@ -3105,12 +3105,9 @@ export default {
/**
* Sets the video muted status.
*
* @param {boolean} muted - New muted status.
*/
setVideoMuteStatus(muted) {
setVideoMuteStatus() {
APP.UI.setVideoMuted(this.getMyUserId());
APP.API.notifyVideoMutedStatusChanged(muted);
},
/**

View File

@ -159,7 +159,7 @@ MiddlewareRegistry.register(store => next => action => {
if (jitsiTrack.type === MEDIA_TYPE.PRESENTER) {
APP.conference.mutePresenter(muted);
} else if (jitsiTrack.isLocal()) {
APP.conference.setVideoMuteStatus(muted);
APP.conference.setVideoMuteStatus();
} else {
APP.UI.setVideoMuted(participantID);
}

View File

@ -4,6 +4,8 @@ import _ from 'lodash';
import { StateListenerRegistry } from '../../base/redux';
import { isLocalCameraTrackMuted } from './functions';
declare var APP: Object;
/**
@ -22,3 +24,20 @@ StateListenerRegistry.register(
}
}
);
/**
* Notifies when the local video mute state changes.
*/
StateListenerRegistry.register(
/* selector */ state => isLocalCameraTrackMuted(state['features/base/tracks']),
/* listener */ (muted, store, previousMuted) => {
if (typeof APP !== 'object') {
return;
}
if (muted !== previousMuted) {
APP.API.notifyVideoMutedStatusChanged(muted);
}
}
);