Przeglądaj źródła

Fixes inconsistent local video muted status.

j8
paweldomas 9 lat temu
rodzic
commit
8469a282c1
2 zmienionych plików z 16 dodań i 22 usunięć
  1. 12
    18
      modules/RTC/LocalStream.js
  2. 4
    4
      modules/RTC/RTC.js

+ 12
- 18
modules/RTC/LocalStream.js Wyświetl plik

@@ -44,29 +44,27 @@ LocalStream.prototype.isAudioStream = function () {
44 44
     return this.type === "audio";
45 45
 };
46 46
 
47
-LocalStream.prototype.setMute = function(mute)
47
+LocalStream.prototype.setMute = function (mute)
48 48
 {
49
+    var isAudio = this.isAudioStream();
50
+    var eventType = isAudio ? RTCEvents.AUDIO_MUTE : RTCEvents.VIDEO_MUTE;
49 51
 
50
-    if((window.location.protocol != "https:" && this.isGUMStream) ||
51
-        (this.isAudioStream() && this.isGUMStream) || this.videoType === "screen")
52
+    if ((window.location.protocol != "https:" && this.isGUMStream) ||
53
+        (isAudio && this.isGUMStream) || this.videoType === "screen")
52 54
     {
53 55
         var tracks = this.getTracks();
54 56
 
55 57
         for (var idx = 0; idx < tracks.length; idx++) {
56
-            tracks[idx].enabled = mute;
58
+            tracks[idx].enabled = !mute;
57 59
         }
58
-        this.eventEmitter.emit(
59
-            (this.type == "audio"? RTCEvents.AUDIO_MUTE : RTCEvents.VIDEO_MUTE),
60
-            !mute);
60
+        this.eventEmitter.emit(eventType, mute);
61 61
     }
62 62
     else
63 63
     {
64
-        if(mute === false) {
64
+        if (mute) {
65 65
             APP.xmpp.removeStream(this.stream);
66 66
             this.stream.stop();
67
-            this.eventEmitter.emit(
68
-                (this.type == "audio"? RTCEvents.AUDIO_MUTE : RTCEvents.VIDEO_MUTE),
69
-                true);
67
+            this.eventEmitter.emit(eventType, true);
70 68
         }
71 69
         else
72 70
         {
@@ -74,22 +72,18 @@ LocalStream.prototype.setMute = function(mute)
74 72
             APP.RTC.rtcUtils.obtainAudioAndVideoPermissions(
75 73
                 (this.isAudioStream() ? ["audio"] : ["video"]),
76 74
                 function (stream) {
77
-                    if(self.isAudioStream())
75
+                    if (isAudio)
78 76
                     {
79 77
                         APP.RTC.changeLocalAudio(stream,
80 78
                             function () {
81
-                                self.eventEmitter.emit(
82
-                                    (self.type == "audio"? RTCEvents.AUDIO_MUTE : RTCEvents.VIDEO_MUTE),
83
-                                    true);
79
+                                self.eventEmitter.emit(eventType, false);
84 80
                             });
85 81
                     }
86 82
                     else
87 83
                     {
88 84
                         APP.RTC.changeLocalVideo(stream, false,
89 85
                             function () {
90
-                                self.eventEmitter.emit(
91
-                                    (self.type == "audio"? RTCEvents.AUDIO_MUTE : RTCEvents.VIDEO_MUTE),
92
-                                    true);
86
+                                self.eventEmitter.emit(eventType, false);
93 87
                             });
94 88
                     }
95 89
                 });

+ 4
- 4
modules/RTC/RTC.js Wyświetl plik

@@ -274,19 +274,19 @@ var RTC = {
274 274
 
275 275
         return isDesktop;
276 276
     },
277
-    setVideoMute: function(mute, callback, options) {
278
-        if(!this.localVideo)
277
+    setVideoMute: function (mute, callback, options) {
278
+        if (!this.localVideo)
279 279
             return;
280 280
 
281 281
         if (mute == APP.RTC.localVideo.isMuted())
282 282
         {
283 283
             APP.xmpp.sendVideoInfoPresence(mute);
284
-            if(callback)
284
+            if (callback)
285 285
                 callback(mute);
286 286
         }
287 287
         else
288 288
         {
289
-            APP.RTC.localVideo.setMute(!mute);
289
+            APP.RTC.localVideo.setMute(mute);
290 290
             APP.xmpp.setVideoMute(
291 291
                 mute,
292 292
                 callback,

Ładowanie…
Anuluj
Zapisz