Преглед изворни кода

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 година
родитељ
комит
6ac23c8086
1 измењених фајлова са 23 додато и 0 уклоњено
  1. 23
    0
      conference.js

+ 23
- 0
conference.js Прегледај датотеку

@@ -422,6 +422,12 @@ function _connectionFailedHandler(error) {
422 422
 }
423 423
 
424 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 431
     isModerator: false,
426 432
     audioMuted: false,
427 433
     videoMuted: false,
@@ -620,6 +626,7 @@ export default {
620 626
                     }
621 627
                 });
622 628
                 logger.log('initialized with %s local tracks', tracks.length);
629
+                this._localTracksInitialized = true;
623 630
                 con.addEventListener(
624 631
                     ConnectionEvents.CONNECTION_FAILED,
625 632
                     _connectionFailedHandler);
@@ -711,6 +718,8 @@ export default {
711 718
      */
712 719
     toggleAudioMuted(force = false) {
713 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 723
             initialAudioMutedState = !initialAudioMutedState;
715 724
             return;
716 725
         }
@@ -723,6 +732,13 @@ export default {
723 732
      * dialogs in case of media permissions error.
724 733
      */
725 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 742
         if (!localVideo && this.videoMuted && !mute) {
727 743
             // Try to create local video if there wasn't any.
728 744
             // This handles the case when user joined with no video
@@ -744,6 +760,13 @@ export default {
744 760
                 })
745 761
                 .then(videoTrack => this.useVideoStream(videoTrack));
746 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 770
             muteLocalVideo(mute);
748 771
         }
749 772
     },

Loading…
Откажи
Сачувај