Merge pull request #1784 from bbaldino/device_list_available_fix

fix an error when testing a result from a method that returns a promise
This commit is contained in:
virtuacoplenny 2017-07-14 15:44:58 -07:00 committed by GitHub
commit 4eef52b84e
1 changed files with 33 additions and 26 deletions

View File

@ -1977,35 +1977,42 @@ export default {
* @private
*/
_initDeviceList() {
if (JitsiMeetJS.mediaDevices.isDeviceListAvailable() &&
JitsiMeetJS.mediaDevices.isDeviceChangeAvailable()) {
JitsiMeetJS.mediaDevices.enumerateDevices(devices => {
// Ugly way to synchronize real device IDs with local
// storage and settings menu. This is a workaround until
// getConstraints() method will be implemented in browsers.
if (localAudio) {
APP.settings.setMicDeviceId(
localAudio.getDeviceId(), false);
}
JitsiMeetJS.mediaDevices.isDeviceListAvailable()
.then(isDeviceListAvailable => {
if (isDeviceListAvailable
&& JitsiMeetJS.mediaDevices.isDeviceChangeAvailable()) {
JitsiMeetJS.mediaDevices.enumerateDevices(devices => {
// Ugly way to synchronize real device IDs with local
// storage and settings menu. This is a workaround until
// getConstraints() method will be implemented
// in browsers.
if (localAudio) {
APP.settings.setMicDeviceId(
localAudio.getDeviceId(), false);
}
if (localVideo) {
APP.settings.setCameraDeviceId(
localVideo.getDeviceId(), false);
}
if (localVideo) {
APP.settings.setCameraDeviceId(
localVideo.getDeviceId(), false);
}
mediaDeviceHelper.setCurrentMediaDevices(devices);
APP.UI.onAvailableDevicesChanged(devices);
APP.store.dispatch(updateDeviceList(devices));
this.updateVideoIconEnabled();
mediaDeviceHelper.setCurrentMediaDevices(devices);
APP.UI.onAvailableDevicesChanged(devices);
APP.store.dispatch(updateDeviceList(devices));
this.updateVideoIconEnabled();
});
this.deviceChangeListener = (devices) =>
window.setTimeout(
() => this._onDeviceListChanged(devices), 0);
JitsiMeetJS.mediaDevices.addEventListener(
JitsiMeetJS.events.mediaDevices.DEVICE_LIST_CHANGED,
this.deviceChangeListener);
}
})
.catch((error) => {
logger.warn(`Error getting device list: ${error}`);
});
this.deviceChangeListener = (devices) =>
window.setTimeout(
() => this._onDeviceListChanged(devices), 0);
JitsiMeetJS.mediaDevices.addEventListener(
JitsiMeetJS.events.mediaDevices.DEVICE_LIST_CHANGED,
this.deviceChangeListener);
}
},
/**
* Event listener for JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED to