Added ability to notify about available media device list changes

This commit is contained in:
Kostiantyn Tsaregradskyi 2016-05-11 16:59:27 +03:00
parent 49e60a8b4f
commit 474155ce9d
3 changed files with 14 additions and 11 deletions

View File

@ -371,11 +371,14 @@ export default {
JitsiMeetJS.isDesktopSharingEnabled();
// update list of available devices
if (JitsiMeetJS.isDeviceListAvailable() &&
JitsiMeetJS.isDeviceChangeAvailable()) {
JitsiMeetJS.enumerateDevices(
devices => APP.UI.onAvailableDevicesChanged(devices)
);
if (JitsiMeetJS.mediaDevices.isDeviceListAvailable() &&
JitsiMeetJS.mediaDevices.isDeviceChangeAvailable()) {
JitsiMeetJS.mediaDevices.enumerateDevices(
APP.UI.onAvailableDevicesChanged);
JitsiMeetJS.mediaDevices.addEventListener(
JitsiMeetJS.events.mediaDevices.DEVICE_LIST_CHANGED,
APP.UI.onAvailableDevicesChanged);
}
if (config.iAmRecorder)
this.recorder = new Recorder();

View File

@ -218,7 +218,7 @@ export default {
);
if (audioOutput.length &&
JitsiMeetJS.isDeviceChangeAvailable('output')) {
JitsiMeetJS.mediaDevices.isDeviceChangeAvailable('output')) {
$selectAudioOutput.html(
generateDevicesOptions(audioOutput,
Settings.getAudioOutputDeviceId()));

View File

@ -45,9 +45,9 @@ if (supportsLocalStorage()) {
var audioOutputDeviceId = window.localStorage.audioOutputDeviceId;
if (typeof audioOutputDeviceId !== 'undefined' &&
audioOutputDeviceId !== JitsiMeetJS.getAudioOutputDevice()) {
JitsiMeetJS.setAudioOutputDevice(
if (typeof audioOutputDeviceId !== 'undefined' && audioOutputDeviceId !==
JitsiMeetJS.mediaDevices.getAudioOutputDevice()) {
JitsiMeetJS.mediaDevices.setAudioOutputDevice(
window.localStorage.audioOutputDeviceId).catch((ex) => {
console.error('failed to set audio output device from local ' +
'storage', ex);
@ -161,7 +161,7 @@ export default {
* @returns {String}
*/
getAudioOutputDeviceId: function () {
return JitsiMeetJS.getAudioOutputDevice();
return JitsiMeetJS.mediaDevices.getAudioOutputDevice();
},
/**
* Set device id of the audio output device which is currently in use.
@ -170,7 +170,7 @@ export default {
* @returns {Promise}
*/
setAudioOutputDeviceId: function (newId = '') {
return JitsiMeetJS.setAudioOutputDevice(newId)
return JitsiMeetJS.mediaDevices.setAudioOutputDevice(newId)
.then(() => window.localStorage.audioOutputDeviceId = newId);
},