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
parent 17613837b6
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;
}

View file

@ -105,7 +105,11 @@ export function GroupCallView({
.data as unknown as JoinCallData;
if (audioInput !== null) {
const deviceId = await findDeviceByName(audioInput, devices);
const deviceId = await findDeviceByName(
audioInput,
"audioinput",
devices
);
if (!deviceId) {
logger.warn("Unknown audio input: " + audioInput);
} else {
@ -117,7 +121,11 @@ export function GroupCallView({
}
if (videoInput !== null) {
const deviceId = await findDeviceByName(videoInput, devices);
const deviceId = await findDeviceByName(
videoInput,
"videoinput",
devices
);
if (!deviceId) {
logger.warn("Unknown video input: " + videoInput);
} else {