Browse Source

fix(conference): early video muted state

If muteVideo is called, before local tracks have been initialized it
will be synced up once the tracks are created (or not).
master
paweldomas 8 years ago
parent
commit
6ac23c8086
1 changed files with 23 additions and 0 deletions
  1. 23
    0
      conference.js

+ 23
- 0
conference.js View File

422
 }
422
 }
423
 
423
 
424
 export default {
424
 export default {
425
+    /**
426
+     * Flag used to delay modification of the muted status of local media tracks
427
+     * until those are created (or not, but at that point it's certain that
428
+     * the tracks won't exist).
429
+     */
430
+    _localTracksInitialized: false,
425
     isModerator: false,
431
     isModerator: false,
426
     audioMuted: false,
432
     audioMuted: false,
427
     videoMuted: false,
433
     videoMuted: false,
620
                     }
626
                     }
621
                 });
627
                 });
622
                 logger.log('initialized with %s local tracks', tracks.length);
628
                 logger.log('initialized with %s local tracks', tracks.length);
629
+                this._localTracksInitialized = true;
623
                 con.addEventListener(
630
                 con.addEventListener(
624
                     ConnectionEvents.CONNECTION_FAILED,
631
                     ConnectionEvents.CONNECTION_FAILED,
625
                     _connectionFailedHandler);
632
                     _connectionFailedHandler);
711
      */
718
      */
712
     toggleAudioMuted(force = false) {
719
     toggleAudioMuted(force = false) {
713
         if(!localAudio && force) {
720
         if(!localAudio && force) {
721
+            // NOTE this logic will be adjusted to the same one as for the video
722
+            // once 'startWithAudioMuted' option is added.
714
             initialAudioMutedState = !initialAudioMutedState;
723
             initialAudioMutedState = !initialAudioMutedState;
715
             return;
724
             return;
716
         }
725
         }
723
      * dialogs in case of media permissions error.
732
      * dialogs in case of media permissions error.
724
      */
733
      */
725
     muteVideo(mute, showUI = true) {
734
     muteVideo(mute, showUI = true) {
735
+        // Not ready to modify track's state yet
736
+        if (!this._localTracksInitialized) {
737
+            this.videoMuted = mute;
738
+
739
+            return;
740
+        }
741
+
726
         if (!localVideo && this.videoMuted && !mute) {
742
         if (!localVideo && this.videoMuted && !mute) {
727
             // Try to create local video if there wasn't any.
743
             // Try to create local video if there wasn't any.
728
             // This handles the case when user joined with no video
744
             // This handles the case when user joined with no video
744
                 })
760
                 })
745
                 .then(videoTrack => this.useVideoStream(videoTrack));
761
                 .then(videoTrack => this.useVideoStream(videoTrack));
746
         } else {
762
         } else {
763
+            // FIXME if localVideo exists and the permissions are blocked
764
+            // while video muted it will fail to unmute and UI will get out of
765
+            // sync (the toolbar will show unmuted even though unmute failed).
766
+            // But for some reason that only happens when toggling off from
767
+            // the audio only mode - the same scenario works fine from toolbar.
768
+            // This is very rare corner case and supposedly this will get fixed
769
+            // once everything goes to react/redux.
747
             muteLocalVideo(mute);
770
             muteLocalVideo(mute);
748
         }
771
         }
749
     },
772
     },

Loading…
Cancel
Save