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

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

j8
Lyubo Marinov пре 8 година
родитељ
комит
cbc08eb96d
2 измењених фајлова са 28 додато и 6 уклоњено
  1. 26
    4
      conference.js
  2. 2
    2
      modules/API/API.js

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

@@ -63,7 +63,8 @@ const ConnectionQualityEvents = JitsiMeetJS.events.connectionQuality;
63 63
 
64 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 70
  * Indicates whether extension external installation is in progress or not.
@@ -581,6 +582,12 @@ export default {
581 582
                 analytics.init();
582 583
                 return createInitialLocalTracksAndConnect(options.roomName);
583 584
             }).then(([tracks, con]) => {
585
+                tracks.forEach(track => {
586
+                    if((track.isAudioTrack() && initialAudioMutedState)
587
+                        || (track.isVideoTrack() && initialVideoMutedState)) {
588
+                        track.mute();
589
+                    }
590
+                });
584 591
                 logger.log('initialized with %s local tracks', tracks.length);
585 592
                 con.addEventListener(
586 593
                     ConnectionEvents.CONNECTION_FAILED,
@@ -648,9 +655,17 @@ export default {
648 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 669
         this.muteAudio(!this.audioMuted);
655 670
     },
656 671
     /**
@@ -662,8 +677,15 @@ export default {
662 677
     },
663 678
     /**
664 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 689
         this.muteVideo(!this.videoMuted);
668 690
     },
669 691
     /**

+ 2
- 2
modules/API/API.js Прегледај датотеку

@@ -43,8 +43,8 @@ function initCommands() {
43 43
     commands = {
44 44
         'display-name':
45 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 48
         'toggle-film-strip': APP.UI.toggleFilmstrip,
49 49
         'toggle-chat': APP.UI.toggleChat,
50 50
         'toggle-contact-list': APP.UI.toggleContactList,

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