Pārlūkot izejas kodu

Subcribe each instance of JitsiLocalTrack to audio output change event as there might be local tracks not inside a conference

dev1
tsareg 9 gadus atpakaļ
vecāks
revīzija
b816184f5b
2 mainītis faili ar 22 papildinājumiem un 10 dzēšanām
  1. 15
    0
      modules/RTC/JitsiLocalTrack.js
  2. 7
    10
      modules/RTC/RTC.js

+ 15
- 0
modules/RTC/JitsiLocalTrack.js Parādīt failu

@@ -69,6 +69,16 @@ function JitsiLocalTrack(stream, track, mediaType, videoType, resolution,
69 69
         }
70 70
     };
71 71
 
72
+    // Subscribe each created local audio track to
73
+    // RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED event. This is different from
74
+    // handling this event for remote tracks (which are handled in RTC.js),
75
+    // because there might be local tracks not attached to a conference.
76
+    if (this.isAudioTrack() && RTCUtils.isDeviceChangeAvailable('output')) {
77
+        this._onAudioOutputDeviceChanged = this.setAudioOutput.bind(this);
78
+
79
+        RTCUtils.addListener(RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED,
80
+            this._onAudioOutputDeviceChanged);
81
+    }
72 82
 
73 83
     RTCUtils.addListener(RTCEvents.DEVICE_LIST_CHANGED,
74 84
         this._onDeviceListChanged);
@@ -288,6 +298,11 @@ JitsiLocalTrack.prototype.dispose = function () {
288 298
     RTCUtils.removeListener(RTCEvents.DEVICE_LIST_CHANGED,
289 299
         this._onDeviceListChanged);
290 300
 
301
+    if (this._onAudioOutputDeviceChanged) {
302
+        RTCUtils.removeListener(RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED,
303
+            this._onAudioOutputDeviceChanged);
304
+    }
305
+
291 306
     return promise;
292 307
 };
293 308
 

+ 7
- 10
modules/RTC/RTC.js Parādīt failu

@@ -61,22 +61,19 @@ function RTC(room, options) {
61 61
         }
62 62
     });
63 63
 
64
-    // switch audio output device on all local and remote audio tracks
65
-    RTCUtils.addListener(RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED,
66
-        function (deviceId) {
67
-            if (RTCUtils.isDeviceChangeAvailable('output')) {
68
-                if (self.localAudio) {
69
-                    self.localAudio.setAudioOutput(deviceId);
70
-                }
71
-
64
+    // Switch audio output device on all remote audio tracks. Local audio tracks
65
+    // handle this event by themselves.
66
+    if (RTCUtils.isDeviceChangeAvailable('output')) {
67
+        RTCUtils.addListener(RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED,
68
+            function (deviceId) {
72 69
                 for (var key in self.remoteTracks) {
73 70
                     if (self.remoteTracks.hasOwnProperty(key)
74 71
                         && self.remoteTracks[key].audio) {
75 72
                         self.remoteTracks[key].audio.setAudioOutput(deviceId);
76 73
                     }
77 74
                 }
78
-            }
79
-        });
75
+            });
76
+    }
80 77
 }
81 78
 
82 79
 /**

Notiek ielāde…
Atcelt
Saglabāt