Skip to content

Commit 0ec5601

Browse files
committed
Remove duplicate media devices from the list
Somehow on my system Firefox always manages to create multiple entries for my webcam. This was an easy enough thing to fix.
1 parent 7edc8af commit 0ec5601

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/livekit/MediaDevicesContext.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ function useMediaDevice(
9797
}
9898

9999
return {
100-
available: available ?? [],
100+
available: available
101+
? // Sometimes browsers (particularly Firefox) can return multiple
102+
// device entries for the exact same device ID; deduplicate them
103+
[...new Map(available.map((d) => [d.deviceId, d])).values()]
104+
: [],
101105
selectedId: alwaysDefault ? undefined : devId,
102106
select,
103107
};

0 commit comments

Comments
 (0)