Description
Hi, team.
I have a preview screen that calls the ZoomVideo.getDevices() on mount, but this returns different results on different browsers. In the worst case, it does not return any devices at all.
Is there a reason this happens? And there is no error on the browser console.
Note: This happens even when the permissions are granted and no other applications are using the camera/audio devices.
Which Web Video SDK version?
1.9.5.
Video SDK Code Snippets
const mountDevices: () => Promise<{
mics: MediaDevice[];
speakers: MediaDevice[];
cameras: MediaDevice[];
}> = async () => {
allDevices = await ZoomVideo.getDevices();
const cameraDevices: Array<MediaDeviceInfo> = allDevices.filter((device) => {
return device.kind === 'videoinput';
});
const micDevices: Array<MediaDeviceInfo> = allDevices.filter((device) => {
return device.kind === 'audioinput';
});
const speakerDevices: Array<MediaDeviceInfo> = allDevices.filter((device) => {
return device.kind === 'audiooutput';
});
return {
mics: micDevices.map((item) => {
return { label: item.label, deviceId: item.deviceId };
}),
speakers: speakerDevices.map((item) => {
return { label: item.label, deviceId: item.deviceId };
}),
cameras: cameraDevices.map((item) => {
return { label: item.label, deviceId: item.deviceId };
})
};
};
before component displays I use the code below to prepopulate the devices
useMount(() => {
PREVIEW_VIDEO = document.getElementById('js-preview-video');
mountDevices().then((devices) => {
console.log('devicesdevicesdevicesdevices', devices);
setMicList(devices.mics);
setCameraList(devices.cameras);
setSpeakerList(devices.speakers);
if (devices.speakers.length > 0) {
setActiveSpeaker(devices.speakers[0].deviceId);
setActiveMicSpeaker(devices.speakers[0].deviceId);
}
if (devices.mics.length > 0) {
setActiveMicrophone(devices.mics[0].deviceId);
}
if (devices.cameras.length > 0) {
setActiveCamera(devices.cameras[0].deviceId);
}
});
});
I would greatly appreciate you feedback. Thanks.
Screenshots
Below screen shot is from Chromium browser, no devices loaded.