isymchych 9 anni fa
parent
commit
44bae94701
1 ha cambiato i file con 38 aggiunte e 31 eliminazioni
  1. 38
    31
      conference.js

+ 38
- 31
conference.js Vedi File

@@ -47,19 +47,6 @@ function connect() {
47 47
     });
48 48
 }
49 49
 
50
-/**
51
- * Add local track to the conference and shares
52
- * video type with other users if its video track.
53
- * @param {JitsiLocalTrack} track local track
54
- */
55
-function addTrack (track) {
56
-    room.addTrack(track);
57
-
58
-    if (track.isAudioTrack()) {
59
-        return;
60
-    }
61
-}
62
-
63 50
 /**
64 51
  * Share email with other users.
65 52
  * @param {string} email new email
@@ -89,6 +76,38 @@ function getDisplayName (id) {
89 76
     }
90 77
 }
91 78
 
79
+/**
80
+ * Mute or unmute local audio stream if it exists.
81
+ * @param {boolean} muted if audio stream should be muted or unmuted.
82
+ */
83
+function muteLocalAudio (muted) {
84
+    if (!localAudio) {
85
+        return;
86
+    }
87
+
88
+    if (muted) {
89
+        localAudio.mute();
90
+    } else {
91
+        localAudio.unmute();
92
+    }
93
+}
94
+
95
+/**
96
+ * Mute or unmute local video stream if it exists.
97
+ * @param {boolean} muted if video stream should be muted or unmuted.
98
+ */
99
+function muteLocalVideo (muted) {
100
+    if (!localVideo) {
101
+        return;
102
+    }
103
+
104
+    if (muted) {
105
+        localVideo.mute();
106
+    } else {
107
+        localVideo.unmute();
108
+    }
109
+}
110
+
92 111
 class ConferenceConnector {
93 112
     constructor(resolve, reject) {
94 113
         this._resolve = resolve;
@@ -274,9 +293,7 @@ export default {
274 293
      * @param mute true for mute and false for unmute.
275 294
      */
276 295
     muteAudio (mute) {
277
-        //FIXME: Maybe we should create method for that in the UI instead of
278
-        //accessing directly eventEmitter????
279
-        APP.UI.eventEmitter.emit(UIEvents.AUDIO_MUTED, mute);
296
+        muteLocalAudio(mute);
280 297
     },
281 298
     /**
282 299
      * Simulates toolbar button click for audio mute. Used by shortcuts and API.
@@ -289,9 +306,7 @@ export default {
289 306
      * @param mute true for mute and false for unmute.
290 307
      */
291 308
     muteVideo (mute) {
292
-        //FIXME: Maybe we should create method for that in the UI instead of
293
-        //accessing directly eventEmitter????
294
-        APP.UI.eventEmitter.emit(UIEvents.VIDEO_MUTED, mute);
309
+        muteLocalVideo(mute);
295 310
     },
296 311
     /**
297 312
      * Simulates toolbar button click for video mute. Used by shortcuts and API.
@@ -413,7 +428,7 @@ export default {
413 428
             else if (track.isVideoTrack()) {
414 429
                 localVideo = track;
415 430
             }
416
-            addTrack(track);
431
+            room.addTrack(track);
417 432
             APP.UI.addLocalStream(track);
418 433
         });
419 434
         roomLocker = createRoomLocker(room);
@@ -600,16 +615,8 @@ export default {
600 615
             }
601 616
         });
602 617
 
603
-        APP.UI.addListener(UIEvents.AUDIO_MUTED, (muted) => {
604
-            if(!localAudio)
605
-                return;
606
-            (muted)? localAudio.mute() : localAudio.unmute();
607
-        });
608
-        APP.UI.addListener(UIEvents.VIDEO_MUTED, (muted) => {
609
-            if(!localVideo)
610
-                return;
611
-            (muted)? localVideo.mute() : localVideo.unmute();
612
-        });
618
+        APP.UI.addListener(UIEvents.AUDIO_MUTED, muteLocalAudio);
619
+        APP.UI.addListener(UIEvents.VIDEO_MUTED, muteLocalVideo);
613 620
 
614 621
         if (!interfaceConfig.filmStripOnly) {
615 622
             APP.UI.addListener(UIEvents.MESSAGE_CREATED, (message) => {
@@ -826,7 +833,7 @@ export default {
826 833
                 if(localVideo)
827 834
                     localVideo.stop();
828 835
                 localVideo = track;
829
-                addTrack(track);
836
+                room.addTrack(track);
830 837
                 if(!room)
831 838
                     localCallback();
832 839
                 APP.UI.addLocalStream(track);

Loading…
Annulla
Salva