Skip to content

Commit 5e31441

Browse files
authored
Fix initial device selection when mounting useMediaDeviceSelect (#1014)
1 parent 370c610 commit 5e31441

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

.changeset/lemon-eggs-collect.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@livekit/components-core": patch
3+
"@livekit/components-react": patch
4+
---
5+
6+
Fix initial device selection when mounting useMediaDeviceSelect

packages/core/src/observables/room.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ export function createActiveDeviceObservable(room: Room, kind: MediaDeviceKind)
249249
log.debug('activeDeviceObservable | RoomEvent.ActiveDeviceChanged', { kind, deviceId });
250250
return deviceId;
251251
}),
252-
startWith(room.getActiveDevice(kind)),
253252
);
254253
}
255254

packages/react/src/hooks/useMediaDeviceSelect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function useMediaDeviceSelect({
6363

6464
React.useEffect(() => {
6565
const listener = activeDeviceObservable.subscribe((deviceId) => {
66-
if (deviceId) {
66+
if (deviceId && deviceId !== currentDeviceId) {
6767
log.info('setCurrentDeviceId', deviceId);
6868
setCurrentDeviceId(deviceId);
6969
}

0 commit comments

Comments
 (0)