浏览代码

code cleanup

j8
isymchych 9 年前
父节点
当前提交
44bae94701
共有 1 个文件被更改,包括 38 次插入31 次删除
  1. 38
    31
      conference.js

+ 38
- 31
conference.js 查看文件

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
  * Share email with other users.
51
  * Share email with other users.
65
  * @param {string} email new email
52
  * @param {string} email new email
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
 class ConferenceConnector {
111
 class ConferenceConnector {
93
     constructor(resolve, reject) {
112
     constructor(resolve, reject) {
94
         this._resolve = resolve;
113
         this._resolve = resolve;
274
      * @param mute true for mute and false for unmute.
293
      * @param mute true for mute and false for unmute.
275
      */
294
      */
276
     muteAudio (mute) {
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
      * Simulates toolbar button click for audio mute. Used by shortcuts and API.
299
      * Simulates toolbar button click for audio mute. Used by shortcuts and API.
289
      * @param mute true for mute and false for unmute.
306
      * @param mute true for mute and false for unmute.
290
      */
307
      */
291
     muteVideo (mute) {
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
      * Simulates toolbar button click for video mute. Used by shortcuts and API.
312
      * Simulates toolbar button click for video mute. Used by shortcuts and API.
413
             else if (track.isVideoTrack()) {
428
             else if (track.isVideoTrack()) {
414
                 localVideo = track;
429
                 localVideo = track;
415
             }
430
             }
416
-            addTrack(track);
431
+            room.addTrack(track);
417
             APP.UI.addLocalStream(track);
432
             APP.UI.addLocalStream(track);
418
         });
433
         });
419
         roomLocker = createRoomLocker(room);
434
         roomLocker = createRoomLocker(room);
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
         if (!interfaceConfig.filmStripOnly) {
621
         if (!interfaceConfig.filmStripOnly) {
615
             APP.UI.addListener(UIEvents.MESSAGE_CREATED, (message) => {
622
             APP.UI.addListener(UIEvents.MESSAGE_CREATED, (message) => {
826
                 if(localVideo)
833
                 if(localVideo)
827
                     localVideo.stop();
834
                     localVideo.stop();
828
                 localVideo = track;
835
                 localVideo = track;
829
-                addTrack(track);
836
+                room.addTrack(track);
830
                 if(!room)
837
                 if(!room)
831
                     localCallback();
838
                     localCallback();
832
                 APP.UI.addLocalStream(track);
839
                 APP.UI.addLocalStream(track);

正在加载...
取消
保存