Skip to content

Commit

Permalink
fix: use correct device label
Browse files Browse the repository at this point in the history
  • Loading branch information
martinstark committed Apr 19, 2024
1 parent b7f5924 commit dc086b5
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/components/production-line/use-device-labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,24 @@ export const useDeviceLabels = ({ joinProductionOptions }: TProps) => {
useEffect(() => {
if (!joinProductionOptions) return;

navigator.mediaDevices.enumerateDevices().then((devices) => {
setDeviceLabels([
devices.find((d) => d.deviceId === joinProductionOptions.audioinput)
?.label,
devices.find((d) => d.deviceId === joinProductionOptions.audiooutput)
?.label,
]);
});
navigator.mediaDevices
.getUserMedia({
audio: true,
})
.then(() => {
navigator.mediaDevices.enumerateDevices().then((devices) => {
setDeviceLabels([
devices
.filter((d) => d.kind === "audioinput")
.find((d) => d.deviceId === joinProductionOptions.audioinput)
?.label,
devices
.filter((d) => d.kind === "audiooutput")
.find((d) => d.deviceId === joinProductionOptions.audiooutput)
?.label,
]);
});
});
}, [joinProductionOptions]);

return deviceLabels
Expand Down

0 comments on commit dc086b5

Please sign in to comment.