Added ability to switch audio output device
This commit is contained in:
parent
2bd600aeaf
commit
d34adb67dd
|
@ -1106,37 +1106,11 @@ export default {
|
|||
APP.UI.addListener(
|
||||
UIEvents.AUDIO_OUTPUT_DEVICE_CHANGED,
|
||||
(audioOutputDeviceId) => {
|
||||
APP.settings.setAudioOutputDeviceId(audioOutputDeviceId);
|
||||
|
||||
let promises = [],
|
||||
track;
|
||||
|
||||
for (let key in room.rtc.remoteTracks) {
|
||||
track = room.rtc.remoteTracks[key].video;
|
||||
|
||||
if (track && track.containers.length) {
|
||||
promises.push(
|
||||
track.changeAudioOutput(audioOutputDeviceId));
|
||||
}
|
||||
|
||||
track = room.rtc.remoteTracks[key].audio;
|
||||
|
||||
if (track && track.containers.length) {
|
||||
promises.push(
|
||||
track.changeAudioOutput(audioOutputDeviceId));
|
||||
}
|
||||
}
|
||||
|
||||
room.rtc.localTracks.forEach((track) => {
|
||||
if (track.containers.length) {
|
||||
promises.push(
|
||||
track.changeAudioOutput(audioOutputDeviceId));
|
||||
}
|
||||
});
|
||||
|
||||
Promise.all(promises).then(
|
||||
() => console.log('audio devices switched'),
|
||||
(err) => console.error(err));
|
||||
APP.settings.setAudioOutputDeviceId(audioOutputDeviceId)
|
||||
.then(() => console.log('changed output device'))
|
||||
.catch((err) => {
|
||||
console.error('failed to set audio output device', err);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@
|
|||
"startVideoMuted": "Start without video",
|
||||
"selectCamera": "Select camera",
|
||||
"selectMic": "Select microphone",
|
||||
"selectAudioOutput": "Select audio output",
|
||||
"followMe": "Enable follow me"
|
||||
},
|
||||
"videothumbnail":
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* global APP, $ */
|
||||
/* global APP, $, JitsiMeetJS */
|
||||
import UIUtil from "../../util/UIUtil";
|
||||
import UIEvents from "../../../../service/UI/UIEvents";
|
||||
import languages from "../../../../service/translation/languages";
|
||||
|
@ -202,7 +202,8 @@ export default {
|
|||
|
||||
let $selectCamera= $('#selectCamera'),
|
||||
$selectMic = $('#selectMic'),
|
||||
$selectAudioOutput = $('#selectAudioOutput');
|
||||
$selectAudioOutput = $('#selectAudioOutput'),
|
||||
$selectAudioOutputParent = $selectAudioOutput.parent();
|
||||
|
||||
let audio = devices.filter(device => device.kind === 'audioinput');
|
||||
let video = devices.filter(device => device.kind === 'videoinput');
|
||||
|
@ -216,15 +217,15 @@ export default {
|
|||
generateDevicesOptions(audio, Settings.getMicDeviceId())
|
||||
);
|
||||
|
||||
if (audioOutput.length) {
|
||||
if (audioOutput.length &&
|
||||
JitsiMeetJS.isAudioOutputDeviceChangeAvailable()) {
|
||||
$selectAudioOutput.html(
|
||||
generateDevicesOptions(audioOutput,
|
||||
Settings.getAudioOutputDeviceId())
|
||||
).show();
|
||||
Settings.getAudioOutputDeviceId()));
|
||||
|
||||
$selectAudioOutputParent.show();
|
||||
} else {
|
||||
// if we have no audiooutput devices, that means current browser
|
||||
// doesn't support it, so don't show the select box at all
|
||||
$selectAudioOutput.hide();
|
||||
$selectAudioOutputParent.hide();
|
||||
}
|
||||
|
||||
$devicesOptions.show();
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* global JitsiMeetJS */
|
||||
|
||||
import UIUtil from '../UI/util/UIUtil';
|
||||
|
||||
let email = '';
|
||||
|
@ -5,7 +7,6 @@ let displayName = '';
|
|||
let language = null;
|
||||
let cameraDeviceId = '';
|
||||
let micDeviceId = '';
|
||||
let audioOutputDeviceId = '';
|
||||
let welcomePageDisabled = false;
|
||||
|
||||
function supportsLocalStorage() {
|
||||
|
@ -39,6 +40,17 @@ if (supportsLocalStorage()) {
|
|||
welcomePageDisabled = JSON.parse(
|
||||
window.localStorage.welcomePageDisabled || false
|
||||
);
|
||||
|
||||
var audioOutputDeviceId = window.localStorage.audioOutputDeviceId;
|
||||
|
||||
if (typeof audioOutputDeviceId !== 'undefined' &&
|
||||
audioOutputDeviceId !== JitsiMeetJS.getAudioOutputDevice()) {
|
||||
JitsiMeetJS.setAudioOutputDevice(
|
||||
window.localStorage.audioOutputDeviceId).catch((ex) => {
|
||||
console.error('failed to set audio output device from local ' +
|
||||
'storage', ex);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log("local storage is not supported");
|
||||
}
|
||||
|
@ -130,16 +142,17 @@ export default {
|
|||
* @returns {String}
|
||||
*/
|
||||
getAudioOutputDeviceId: function () {
|
||||
return audioOutputDeviceId;
|
||||
return JitsiMeetJS.getAudioOutputDevice();
|
||||
},
|
||||
/**
|
||||
* Set device id of the audio output device which is currently in use.
|
||||
* Empty string stands for default device.
|
||||
* @param {string} newId new audio output device id
|
||||
* @returns {Promise}
|
||||
*/
|
||||
setAudioOutputDeviceId: function (newId = '') {
|
||||
audioOutputDeviceId = newId;
|
||||
window.localStorage.audioOutputDeviceId = newId;
|
||||
return JitsiMeetJS.setAudioOutputDevice(newId)
|
||||
.then(() => window.localStorage.audioOutputDeviceId = newId);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue