Przeglądaj źródła

Init "currentlyAvailableMediaDevices" var for the first enumerateDevices() and don't fire event in this case

dev1
tsareg 9 lat temu
rodzic
commit
88f5b6be45
1 zmienionych plików z 6 dodań i 2 usunięć
  1. 6
    2
      modules/RTC/RTCUtils.js

+ 6
- 2
modules/RTC/RTCUtils.js Wyświetl plik

@@ -40,7 +40,7 @@ var featureDetectionAudioEl = document.createElement('audio');
40 40
 var isAudioOutputDeviceChangeAvailable =
41 41
     typeof featureDetectionAudioEl.setSinkId !== 'undefined';
42 42
 
43
-var currentlyAvailableMediaDevices = [];
43
+var currentlyAvailableMediaDevices;
44 44
 
45 45
 var rawEnumerateDevicesWithCallback = navigator.mediaDevices
46 46
     && navigator.mediaDevices.enumerateDevices
@@ -305,7 +305,11 @@ function pollForAvailableMediaDevices() {
305 305
     // and then plug in a new one.
306 306
     if (rawEnumerateDevicesWithCallback) {
307 307
         rawEnumerateDevicesWithCallback(function (devices) {
308
-            if (compareAvailableMediaDevices(devices)) {
308
+            // We don't fire RTCEvents.DEVICE_LIST_CHANGED for the first time
309
+            // we call enumerateDevices(). This is the initial step.
310
+            if (typeof currentlyAvailableMediaDevices === 'undefined') {
311
+                currentlyAvailableMediaDevices = devices.slice(0);
312
+            } else if (compareAvailableMediaDevices(devices)) {
309 313
                 onMediaDevicesListChanged(devices);
310 314
             }
311 315
 

Ładowanie…
Anuluj
Zapisz