Match device type too

Because lots of audio & video inputs have the same name
This commit is contained in:
David Baker 2022-09-29 17:07:10 +01:00
commit 77da0c912f
2 changed files with 14 additions and 3 deletions

View file

@ -24,9 +24,12 @@ import { logger } from "matrix-js-sdk/src/logger";
*/
export async function findDeviceByName(
deviceName: string,
kind: MediaDeviceKind,
devices: MediaDeviceInfo[]
): Promise<string | undefined> {
const deviceInfo = devices.find((d) => d.label === deviceName);
const deviceInfo = devices.find(
(d) => d.kind === kind && d.label === deviceName
);
return deviceInfo?.deviceId;
}