const getDeviceGroup = (mainDevInfo) => {
let devList = [];
navigator.mediaDevices.enumerateDevices().then((devices) => {
devices.forEach((device) => {
if (device.groupId === mainDevInfo.groupId) {
devList.push(device);
}
});
});
return devList;
};MediaDeviceInfo: groupId property / notebook
MediaDeviceInfo: groupId property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const getDeviceGroup = (mainDevInfo) => {
let devList = [mainDevInfo];
navigator.mediaDevices.enumerateDevices().then((devices) => {
devices.forEach((device) => {
if (
device.groupId === mainDevInfo.groupId &&
device.deviceId !== mainDevInfo.deviceId
) {
devList.push(device);
}
});
});
return devList;
};