Browse Source

Merge remote-tracking branch 'origin/race_conditions' into api_eslint

j8
Lyubo Marinov 8 years ago
parent
commit
cbc08eb96d
2 changed files with 28 additions and 6 deletions
  1. 26
    4
      conference.js
  2. 2
    2
      modules/API/API.js

+ 26
- 4
conference.js View File

63
 
63
 
64
 const eventEmitter = new EventEmitter();
64
 const eventEmitter = new EventEmitter();
65
 
65
 
66
-let room, connection, localAudio, localVideo;
66
+let room, connection, localAudio, localVideo,
67
+    initialAudioMutedState = false, initialVideoMutedState = false;
67
 
68
 
68
 /**
69
 /**
69
  * Indicates whether extension external installation is in progress or not.
70
  * Indicates whether extension external installation is in progress or not.
581
                 analytics.init();
582
                 analytics.init();
582
                 return createInitialLocalTracksAndConnect(options.roomName);
583
                 return createInitialLocalTracksAndConnect(options.roomName);
583
             }).then(([tracks, con]) => {
584
             }).then(([tracks, con]) => {
585
+                tracks.forEach(track => {
586
+                    if((track.isAudioTrack() && initialAudioMutedState)
587
+                        || (track.isVideoTrack() && initialVideoMutedState)) {
588
+                        track.mute();
589
+                    }
590
+                });
584
                 logger.log('initialized with %s local tracks', tracks.length);
591
                 logger.log('initialized with %s local tracks', tracks.length);
585
                 con.addEventListener(
592
                 con.addEventListener(
586
                     ConnectionEvents.CONNECTION_FAILED,
593
                     ConnectionEvents.CONNECTION_FAILED,
648
         return this.audioMuted;
655
         return this.audioMuted;
649
     },
656
     },
650
     /**
657
     /**
651
-     * Simulates toolbar button click for audio mute. Used by shortcuts and API.
658
+     * Simulates toolbar button click for audio mute. Used by shortcuts
659
+     * and API.
660
+     * @param {boolean} force - If the track is not created, the operation
661
+     * will be executed after the track is created. Otherwise the operation
662
+     * will be ignored.
652
      */
663
      */
653
-    toggleAudioMuted () {
664
+    toggleAudioMuted (force = false) {
665
+        if(!localAudio && force) {
666
+            initialAudioMutedState = !initialAudioMutedState;
667
+            return;
668
+        }
654
         this.muteAudio(!this.audioMuted);
669
         this.muteAudio(!this.audioMuted);
655
     },
670
     },
656
     /**
671
     /**
662
     },
677
     },
663
     /**
678
     /**
664
      * Simulates toolbar button click for video mute. Used by shortcuts and API.
679
      * Simulates toolbar button click for video mute. Used by shortcuts and API.
680
+     * @param {boolean} force - If the track is not created, the operation
681
+     * will be executed after the track is created. Otherwise the operation
682
+     * will be ignored.
665
      */
683
      */
666
-    toggleVideoMuted () {
684
+    toggleVideoMuted (force = false) {
685
+        if(!localVideo && force) {
686
+            initialVideoMutedState = !initialVideoMutedState;
687
+            return;
688
+        }
667
         this.muteVideo(!this.videoMuted);
689
         this.muteVideo(!this.videoMuted);
668
     },
690
     },
669
     /**
691
     /**

+ 2
- 2
modules/API/API.js View File

43
     commands = {
43
     commands = {
44
         'display-name':
44
         'display-name':
45
             APP.conference.changeLocalDisplayName.bind(APP.conference),
45
             APP.conference.changeLocalDisplayName.bind(APP.conference),
46
-        'toggle-audio': APP.conference.toggleAudioMuted.bind(APP.conference),
47
-        'toggle-video': APP.conference.toggleVideoMuted.bind(APP.conference),
46
+        'toggle-audio': () => APP.conference.toggleAudioMuted(true),
47
+        'toggle-video': () => APP.conference.toggleVideoMuted(true),
48
         'toggle-film-strip': APP.UI.toggleFilmstrip,
48
         'toggle-film-strip': APP.UI.toggleFilmstrip,
49
         'toggle-chat': APP.UI.toggleChat,
49
         'toggle-chat': APP.UI.toggleChat,
50
         'toggle-contact-list': APP.UI.toggleContactList,
50
         'toggle-contact-list': APP.UI.toggleContactList,

Loading…
Cancel
Save