From cc65c8482001038d4c5b03306ac40ec04bce7269 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Tue, 12 Mar 2024 19:25:16 +0100 Subject: [PATCH] Read deviceId from source mediastreamtrack (#1068) --- .changeset/eleven-ravens-wonder.md | 5 +++++ src/room/track/LocalAudioTrack.ts | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 .changeset/eleven-ravens-wonder.md diff --git a/.changeset/eleven-ravens-wonder.md b/.changeset/eleven-ravens-wonder.md new file mode 100644 index 0000000000..ed4a6690b1 --- /dev/null +++ b/.changeset/eleven-ravens-wonder.md @@ -0,0 +1,5 @@ +--- +"livekit-client": patch +--- + +Read deviceId from source mediastreamtrack diff --git a/src/room/track/LocalAudioTrack.ts b/src/room/track/LocalAudioTrack.ts index 3fb00a4b0d..a21c603e9f 100644 --- a/src/room/track/LocalAudioTrack.ts +++ b/src/room/track/LocalAudioTrack.ts @@ -36,7 +36,10 @@ export default class LocalAudioTrack extends LocalTrack { } async setDeviceId(deviceId: ConstrainDOMString): Promise { - if (this._constraints.deviceId === deviceId) { + if ( + this._constraints.deviceId === deviceId && + this._mediaStreamTrack.getSettings().deviceId === unwrapConstraint(deviceId) + ) { return true; } this._constraints.deviceId = deviceId; @@ -44,7 +47,7 @@ export default class LocalAudioTrack extends LocalTrack { await this.restartTrack(); } return ( - this.isMuted || unwrapConstraint(deviceId) === this.mediaStreamTrack.getSettings().deviceId + this.isMuted || unwrapConstraint(deviceId) === this._mediaStreamTrack.getSettings().deviceId ); }