Ver código fonte

fix: unmute video on audio only switch off

Will unmute local video (and ask for permissions if needed) in case user
started in audio only mode and is turing it off.
j8
paweldomas 8 anos atrás
pai
commit
a5f61714bd
2 arquivos alterados com 45 adições e 39 exclusões
  1. 42
    38
      conference.js
  2. 3
    1
      modules/API/API.js

+ 42
- 38
conference.js Ver arquivo

72
 let room;
72
 let room;
73
 let connection;
73
 let connection;
74
 let localAudio, localVideo;
74
 let localAudio, localVideo;
75
-let initialAudioMutedState = false, initialVideoMutedState = false;
75
+let initialAudioMutedState = false;
76
 
76
 
77
 import {VIDEO_CONTAINER_TYPE} from "./modules/UI/videolayout/VideoContainer";
77
 import {VIDEO_CONTAINER_TYPE} from "./modules/UI/videolayout/VideoContainer";
78
 
78
 
495
 
495
 
496
                         return [];
496
                         return [];
497
                     });
497
                     });
498
+
499
+            // Enable audio only mode
500
+            if (config.startAudioOnly) {
501
+                APP.store.dispatch(toggleAudioOnly());
502
+            }
498
         } else if (options.startScreenSharing) {
503
         } else if (options.startScreenSharing) {
499
             tryCreateLocalTracks = this._createDesktopTrack()
504
             tryCreateLocalTracks = this._createDesktopTrack()
500
                 .then(desktopStream => {
505
                 .then(desktopStream => {
608
                     });
613
                     });
609
             }).then(([tracks, con]) => {
614
             }).then(([tracks, con]) => {
610
                 tracks.forEach(track => {
615
                 tracks.forEach(track => {
611
-                    if((track.isAudioTrack() && initialAudioMutedState)
612
-                        || (track.isVideoTrack() && initialVideoMutedState)) {
616
+                    if (track.isAudioTrack() && initialAudioMutedState) {
617
+                        track.mute();
618
+                    } else if (track.isVideoTrack() && this.videoMuted) {
613
                         track.mute();
619
                         track.mute();
614
                     }
620
                     }
615
                 });
621
                 });
662
                     this.updateVideoIconEnabled();
668
                     this.updateVideoIconEnabled();
663
                 }
669
                 }
664
 
670
 
665
-                // Enable audio only mode
666
-                if (config.startAudioOnly) {
667
-                    // It is important to have that toggled after video muted
668
-                    // state is adjusted by the code about lack of video tracks
669
-                    // above. That's because audio only will store muted state
670
-                    // on toggle action.
671
-                    APP.store.dispatch(toggleAudioOnly());
672
-                }
673
-
674
                 this._initDeviceList();
671
                 this._initDeviceList();
675
 
672
 
676
                 if (config.iAmRecorder)
673
                 if (config.iAmRecorder)
722
     /**
719
     /**
723
      * Simulates toolbar button click for video mute. Used by shortcuts and API.
720
      * Simulates toolbar button click for video mute. Used by shortcuts and API.
724
      * @param mute true for mute and false for unmute.
721
      * @param mute true for mute and false for unmute.
725
-     */
726
-    muteVideo(mute) {
727
-        muteLocalVideo(mute);
722
+     * @param {boolean} [showUI] when set to false will not display any error
723
+     * dialogs in case of media permissions error.
724
+     */
725
+    muteVideo(mute, showUI = true) {
726
+        if (!localVideo && this.videoMuted && !mute) {
727
+            // Try to create local video if there wasn't any.
728
+            // This handles the case when user joined with no video
729
+            // (dismissed screen sharing screen or in audio only mode), but
730
+            // decided to add it later on by clicking on muted video icon or
731
+            // turning off the audio only mode.
732
+            //
733
+            // FIXME when local track creation is moved to react/redux
734
+            // it should take care of the use case described above
735
+            createLocalTracks({ devices: ['video'] }, false)
736
+                .then(([videoTrack]) => videoTrack)
737
+                .catch(error => {
738
+                    // FIXME should send some feedback to the API on error ?
739
+                    if (showUI) {
740
+                        APP.UI.showDeviceErrorDialog(null, error);
741
+                    }
742
+                    // Rollback the video muted status by using null track
743
+                    return null;
744
+                })
745
+                .then(videoTrack => this.useVideoStream(videoTrack));
746
+        } else {
747
+            muteLocalVideo(mute);
748
+        }
728
     },
749
     },
729
     /**
750
     /**
730
      * Simulates toolbar button click for video mute. Used by shortcuts and API.
751
      * Simulates toolbar button click for video mute. Used by shortcuts and API.
731
-     * @param {boolean} force - If the track is not created, the operation
732
-     * will be executed after the track is created. Otherwise the operation
733
-     * will be ignored.
752
+     * @param {boolean} [showUI] when set to false will not display any error
753
+     * dialogs in case of media permissions error.
734
      */
754
      */
735
-    toggleVideoMuted(force = false) {
736
-        if(!localVideo && force) {
737
-            initialVideoMutedState = !initialVideoMutedState;
738
-            return;
739
-        }
740
-        this.muteVideo(!this.videoMuted);
755
+    toggleVideoMuted(showUI = true) {
756
+        this.muteVideo(!this.videoMuted, showUI);
741
     },
757
     },
742
     /**
758
     /**
743
      * Retrieve list of conference participants (without local user).
759
      * Retrieve list of conference participants (without local user).
1731
         APP.UI.addListener(UIEvents.VIDEO_MUTED, muted => {
1747
         APP.UI.addListener(UIEvents.VIDEO_MUTED, muted => {
1732
             if (this.isAudioOnly() && !muted) {
1748
             if (this.isAudioOnly() && !muted) {
1733
                 this._displayAudioOnlyTooltip('videoMute');
1749
                 this._displayAudioOnlyTooltip('videoMute');
1734
-            } else if (!localVideo && this.videoMuted && !muted) {
1735
-                // Maybe try to create local video if there wasn't any ?
1736
-                // This handles the case when user joined with no video
1737
-                // (dismissed screen sharing screen), but decided to add it
1738
-                // later on by clicking on muted video icon.
1739
-                createLocalTracks({ devices: ['video'] }, false)
1740
-                    .then(([videoTrack]) => {
1741
-                        APP.conference.useVideoStream(videoTrack);
1742
-                    })
1743
-                    .catch(error => {
1744
-                        APP.UI.showDeviceErrorDialog(null, error);
1745
-                    });
1746
             } else {
1750
             } else {
1747
-                muteLocalVideo(muted);
1751
+                this.muteVideo(muted);
1748
             }
1752
             }
1749
         });
1753
         });
1750
 
1754
 
1946
         );
1950
         );
1947
 
1951
 
1948
         APP.UI.addListener(UIEvents.TOGGLE_AUDIO_ONLY, audioOnly => {
1952
         APP.UI.addListener(UIEvents.TOGGLE_AUDIO_ONLY, audioOnly => {
1949
-            muteLocalVideo(audioOnly);
1953
+            this.muteVideo(audioOnly);
1950
 
1954
 
1951
             // Immediately update the UI by having remote videos and the large
1955
             // Immediately update the UI by having remote videos and the large
1952
             // video update themselves instead of waiting for some other event
1956
             // video update themselves instead of waiting for some other event

+ 3
- 1
modules/API/API.js Ver arquivo

36
         'display-name':
36
         'display-name':
37
             APP.conference.changeLocalDisplayName.bind(APP.conference),
37
             APP.conference.changeLocalDisplayName.bind(APP.conference),
38
         'toggle-audio': () => APP.conference.toggleAudioMuted(true),
38
         'toggle-audio': () => APP.conference.toggleAudioMuted(true),
39
-        'toggle-video': () => APP.conference.toggleVideoMuted(true),
39
+        'toggle-video': () => {
40
+            APP.conference.toggleVideoMuted(false /* no UI */);
41
+        },
40
         'toggle-film-strip': APP.UI.toggleFilmstrip,
42
         'toggle-film-strip': APP.UI.toggleFilmstrip,
41
         'toggle-chat': APP.UI.toggleChat,
43
         'toggle-chat': APP.UI.toggleChat,
42
         'toggle-contact-list': APP.UI.toggleContactList,
44
         'toggle-contact-list': APP.UI.toggleContactList,

Carregando…
Cancelar
Salvar