From ff5ecab6f50e9b5bd5f0096816aebc1ab161b940 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 6 Oct 2023 15:44:22 +0100 Subject: [PATCH] Switch devices if the label doesn't match the default --- src/livekit/useLiveKit.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/livekit/useLiveKit.ts b/src/livekit/useLiveKit.ts index bf12669c..7603b124 100644 --- a/src/livekit/useLiveKit.ts +++ b/src/livekit/useLiveKit.ts @@ -188,8 +188,9 @@ export function useLiveKit( // Plus, we need to avoid restarting again if the track is already in // the process of being restarted. activeMicTrack.mediaStreamTrack.readyState !== "ended" && - defaultDevice.groupId !== - activeMicTrack.mediaStreamTrack.getSettings().groupId + (defaultDevice.groupId !== + activeMicTrack.mediaStreamTrack.getSettings().groupId || + defaultDevice.label !== activeMicTrack.mediaStreamTrack.label) ) { // It's different, so restart the track, ie. cause Livekit to do another // getUserMedia() call with deviceId: default to get the *new* default device.