Просмотр исходного кода

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

- small refactor to trigger `notifyVideoMutedStatusChanged` correctly when participant is presenting
master
hmuresan 4 лет назад
Родитель
Сommit
b998d80ee3
3 измененных файлов: 26 добавлений и 10 удалений
  1. 6
    9
      conference.js
  2. 1
    1
      react/features/base/tracks/middleware.js
  3. 19
    0
      react/features/base/tracks/subscriber.js

+ 6
- 9
conference.js Просмотреть файл

@@ -739,7 +739,7 @@ export default {
739 739
         }
740 740
 
741 741
         if (!tracks.find(t => t.isVideoTrack())) {
742
-            this.setVideoMuteStatus(true);
742
+            this.setVideoMuteStatus();
743 743
         }
744 744
 
745 745
         if (config.iAmRecorder) {
@@ -993,7 +993,7 @@ export default {
993 993
             // This will only modify base/media.video.muted which is then synced
994 994
             // up with the track at the end of local tracks initialization.
995 995
             muteLocalVideo(mute);
996
-            this.setVideoMuteStatus(mute);
996
+            this.setVideoMuteStatus();
997 997
 
998 998
             return;
999 999
         } else if (this.isLocalVideoMuted() === mute) {
@@ -1402,7 +1402,7 @@ export default {
1402 1402
                     .then(() => {
1403 1403
                         this.localVideo = newTrack;
1404 1404
                         this._setSharingScreen(newTrack);
1405
-                        this.setVideoMuteStatus(this.isLocalVideoMuted());
1405
+                        this.setVideoMuteStatus();
1406 1406
                     })
1407 1407
                     .then(resolve)
1408 1408
                     .catch(error => {
@@ -1821,7 +1821,7 @@ export default {
1821 1821
             try {
1822 1822
                 await this.localVideo.setEffect(effect);
1823 1823
                 APP.store.dispatch(setVideoMuted(mute, MEDIA_TYPE.PRESENTER));
1824
-                this.setVideoMuteStatus(mute);
1824
+                this.setVideoMuteStatus();
1825 1825
             } catch (err) {
1826 1826
                 logger.error('Failed to apply the Presenter effect', err);
1827 1827
             }
@@ -2303,7 +2303,7 @@ export default {
2303 2303
                     return this._createPresenterStreamEffect(height, cameraDeviceId)
2304 2304
                         .then(effect => this.localVideo.setEffect(effect))
2305 2305
                         .then(() => {
2306
-                            this.setVideoMuteStatus(false);
2306
+                            this.setVideoMuteStatus();
2307 2307
                             logger.log('Switched local video device while screen sharing and the video is unmuted');
2308 2308
                             this._updateVideoDeviceId();
2309 2309
                         })
@@ -3105,12 +3105,9 @@ export default {
3105 3105
 
3106 3106
     /**
3107 3107
      * Sets the video muted status.
3108
-     *
3109
-     * @param {boolean} muted - New muted status.
3110 3108
      */
3111
-    setVideoMuteStatus(muted) {
3109
+    setVideoMuteStatus() {
3112 3110
         APP.UI.setVideoMuted(this.getMyUserId());
3113
-        APP.API.notifyVideoMutedStatusChanged(muted);
3114 3111
     },
3115 3112
 
3116 3113
     /**

+ 1
- 1
react/features/base/tracks/middleware.js Просмотреть файл

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

+ 19
- 0
react/features/base/tracks/subscriber.js Просмотреть файл

@@ -4,6 +4,8 @@ import _ from 'lodash';
4 4
 
5 5
 import { StateListenerRegistry } from '../../base/redux';
6 6
 
7
+import { isLocalCameraTrackMuted } from './functions';
8
+
7 9
 declare var APP: Object;
8 10
 
9 11
 /**
@@ -22,3 +24,20 @@ StateListenerRegistry.register(
22 24
         }
23 25
     }
24 26
 );
27
+
28
+
29
+/**
30
+ * Notifies when the local video mute state changes.
31
+ */
32
+StateListenerRegistry.register(
33
+    /* selector */ state => isLocalCameraTrackMuted(state['features/base/tracks']),
34
+    /* listener */ (muted, store, previousMuted) => {
35
+        if (typeof APP !== 'object') {
36
+            return;
37
+        }
38
+
39
+        if (muted !== previousMuted) {
40
+            APP.API.notifyVideoMutedStatusChanged(muted);
41
+        }
42
+    }
43
+);

Загрузка…
Отмена
Сохранить