Przeglądaj źródła

fix an error when testing a result from a method that returns a promise

j8
bbaldino 7 lat temu
rodzic
commit
7d99c54ec8
1 zmienionych plików z 33 dodań i 26 usunięć
  1. 33
    26
      conference.js

+ 33
- 26
conference.js Wyświetl plik

@@ -1977,35 +1977,42 @@ export default {
1977 1977
      * @private
1978 1978
      */
1979 1979
     _initDeviceList() {
1980
-        if (JitsiMeetJS.mediaDevices.isDeviceListAvailable() &&
1981
-            JitsiMeetJS.mediaDevices.isDeviceChangeAvailable()) {
1982
-            JitsiMeetJS.mediaDevices.enumerateDevices(devices => {
1983
-                // Ugly way to synchronize real device IDs with local
1984
-                // storage and settings menu. This is a workaround until
1985
-                // getConstraints() method will be implemented in browsers.
1986
-                if (localAudio) {
1987
-                    APP.settings.setMicDeviceId(
1988
-                        localAudio.getDeviceId(), false);
1989
-                }
1980
+        JitsiMeetJS.mediaDevices.isDeviceListAvailable()
1981
+            .then(isDeviceListAvailable => {
1982
+                if (isDeviceListAvailable
1983
+                        && JitsiMeetJS.mediaDevices.isDeviceChangeAvailable()) {
1984
+                    JitsiMeetJS.mediaDevices.enumerateDevices(devices => {
1985
+                        // Ugly way to synchronize real device IDs with local
1986
+                        // storage and settings menu. This is a workaround until
1987
+                        // getConstraints() method will be implemented 
1988
+                        // in browsers.
1989
+                        if (localAudio) {
1990
+                            APP.settings.setMicDeviceId(
1991
+                                localAudio.getDeviceId(), false);
1992
+                        }
1990 1993
 
1991
-                if (localVideo) {
1992
-                    APP.settings.setCameraDeviceId(
1993
-                        localVideo.getDeviceId(), false);
1994
-                }
1994
+                        if (localVideo) {
1995
+                            APP.settings.setCameraDeviceId(
1996
+                                localVideo.getDeviceId(), false);
1997
+                        }
1995 1998
 
1996
-                mediaDeviceHelper.setCurrentMediaDevices(devices);
1997
-                APP.UI.onAvailableDevicesChanged(devices);
1998
-                APP.store.dispatch(updateDeviceList(devices));
1999
-                this.updateVideoIconEnabled();
2000
-            });
1999
+                        mediaDeviceHelper.setCurrentMediaDevices(devices);
2000
+                        APP.UI.onAvailableDevicesChanged(devices);
2001
+                        APP.store.dispatch(updateDeviceList(devices));
2002
+                        this.updateVideoIconEnabled();
2003
+                    });
2001 2004
 
2002
-            this.deviceChangeListener = (devices) =>
2003
-                window.setTimeout(
2004
-                    () => this._onDeviceListChanged(devices), 0);
2005
-            JitsiMeetJS.mediaDevices.addEventListener(
2006
-                JitsiMeetJS.events.mediaDevices.DEVICE_LIST_CHANGED,
2007
-                this.deviceChangeListener);
2008
-        }
2005
+                    this.deviceChangeListener = (devices) =>
2006
+                        window.setTimeout(
2007
+                            () => this._onDeviceListChanged(devices), 0);
2008
+                    JitsiMeetJS.mediaDevices.addEventListener(
2009
+                        JitsiMeetJS.events.mediaDevices.DEVICE_LIST_CHANGED,
2010
+                        this.deviceChangeListener);
2011
+                }
2012
+            })
2013
+            .catch((error) => {
2014
+                logger.warn(`Error getting device list: ${error}`);
2015
+            });
2009 2016
     },
2010 2017
     /**
2011 2018
      * Event listener for JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED to

Ładowanie…
Anuluj
Zapisz