Sfoglia il codice sorgente

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

master
tsareg 9 anni fa
parent
commit
b816184f5b
2 ha cambiato i file con 22 aggiunte e 10 eliminazioni
  1. 15
    0
      modules/RTC/JitsiLocalTrack.js
  2. 7
    10
      modules/RTC/RTC.js

+ 15
- 0
modules/RTC/JitsiLocalTrack.js Vedi File

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
     RTCUtils.addListener(RTCEvents.DEVICE_LIST_CHANGED,
83
     RTCUtils.addListener(RTCEvents.DEVICE_LIST_CHANGED,
74
         this._onDeviceListChanged);
84
         this._onDeviceListChanged);
288
     RTCUtils.removeListener(RTCEvents.DEVICE_LIST_CHANGED,
298
     RTCUtils.removeListener(RTCEvents.DEVICE_LIST_CHANGED,
289
         this._onDeviceListChanged);
299
         this._onDeviceListChanged);
290
 
300
 
301
+    if (this._onAudioOutputDeviceChanged) {
302
+        RTCUtils.removeListener(RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED,
303
+            this._onAudioOutputDeviceChanged);
304
+    }
305
+
291
     return promise;
306
     return promise;
292
 };
307
 };
293
 
308
 

+ 7
- 10
modules/RTC/RTC.js Vedi File

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
                 for (var key in self.remoteTracks) {
69
                 for (var key in self.remoteTracks) {
73
                     if (self.remoteTracks.hasOwnProperty(key)
70
                     if (self.remoteTracks.hasOwnProperty(key)
74
                         && self.remoteTracks[key].audio) {
71
                         && self.remoteTracks[key].audio) {
75
                         self.remoteTracks[key].audio.setAudioOutput(deviceId);
72
                         self.remoteTracks[key].audio.setAudioOutput(deviceId);
76
                     }
73
                     }
77
                 }
74
                 }
78
-            }
79
-        });
75
+            });
76
+    }
80
 }
77
 }
81
 
78
 
82
 /**
79
 /**

Loading…
Annulla
Salva