in src/providers/MeetingProvider/MeetingManager.ts [404:480]
async listAndSelectDevices(
deviceLabels: DeviceLabels | DeviceLabelTrigger = DeviceLabels.AudioAndVideo
): Promise<void> {
await this.updateDeviceLists();
// If `deviceLabels` is of `DeviceLabelTrigger` type, no device will be selected.
// In this case, you need to handle the device selection yourself.
if (typeof deviceLabels === 'function') return;
let isAudioDeviceRequested: boolean = false;
let isVideoDeviceRequested: boolean = false;
switch (deviceLabels) {
case DeviceLabels.None:
break;
case DeviceLabels.Audio:
isAudioDeviceRequested = true;
break;
case DeviceLabels.Video:
isVideoDeviceRequested = true;
break;
case DeviceLabels.AudioAndVideo:
isAudioDeviceRequested = true;
isVideoDeviceRequested = true;
break;
}
if (
isAudioDeviceRequested &&
!this.selectedAudioInputDevice &&
this.audioInputDevices &&
this.audioInputDevices.length
) {
this.selectedAudioInputDevice = this.audioInputDevices[0].deviceId;
try {
await this.audioVideo?.startAudioInput(
this.audioInputDevices[0].deviceId
);
} catch (error) {
console.error(
'MeetingManager failed to select audio input device on join',
error
);
}
this.publishSelectedAudioInputDevice();
}
if (
isAudioDeviceRequested &&
!this.selectedAudioOutputDevice &&
this.audioOutputDevices &&
this.audioOutputDevices.length
) {
this.selectedAudioOutputDevice = this.audioOutputDevices[0].deviceId;
if (new DefaultBrowserBehavior().supportsSetSinkId()) {
try {
await this.audioVideo?.chooseAudioOutput(
this.audioOutputDevices[0].deviceId
);
} catch (error) {
console.error(
'MeetingManager failed to select audio output device on join',
error
);
}
}
this.publishSelectedAudioOutputDevice();
}
if (
isVideoDeviceRequested &&
!this.selectedVideoInputDevice &&
this.videoInputDevices &&
this.videoInputDevices.length
) {
this.selectedVideoInputDevice = this.videoInputDevices[0].deviceId;
this.publishSelectedVideoInputDevice();
}
}