Skip to content

Commit 58245a1

Browse files
authored
Emit ActiveDeviceChanged event also for audio-output (#1372)
1 parent cd425c8 commit 58245a1

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.changeset/gorgeous-kings-serve.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"livekit-client": patch
3+
---
4+
5+
Emit ActiveDeviceChanged event also for audio-output

src/room/Room.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,8 +1184,12 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
11841184
throw e;
11851185
}
11861186
}
1187-
if (needsUpdateWithoutTracks) {
1188-
this.localParticipant.activeDeviceMap.set(kind, deviceId);
1187+
if (needsUpdateWithoutTracks || kind === 'audiooutput') {
1188+
// if there are not active tracks yet or we're switching audiooutput, we need to manually update the active device map here as changing audio output won't result in a track restart
1189+
this.localParticipant.activeDeviceMap.set(
1190+
kind,
1191+
(kind === 'audiooutput' && this.options.audioOutput?.deviceId) || deviceId,
1192+
);
11891193
this.emit(RoomEvent.ActiveDeviceChanged, kind, deviceId);
11901194
}
11911195

0 commit comments

Comments
 (0)