Skip to content

Commit

Permalink
Read deviceId from source mediastreamtrack (#1068)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasIO authored Mar 12, 2024
1 parent c39362f commit cc65c84
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-ravens-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Read deviceId from source mediastreamtrack
7 changes: 5 additions & 2 deletions src/room/track/LocalAudioTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ export default class LocalAudioTrack extends LocalTrack<Track.Kind.Audio> {
}

async setDeviceId(deviceId: ConstrainDOMString): Promise<boolean> {
if (this._constraints.deviceId === deviceId) {
if (
this._constraints.deviceId === deviceId &&
this._mediaStreamTrack.getSettings().deviceId === unwrapConstraint(deviceId)
) {
return true;
}
this._constraints.deviceId = deviceId;
if (!this.isMuted) {
await this.restartTrack();
}
return (
this.isMuted || unwrapConstraint(deviceId) === this.mediaStreamTrack.getSettings().deviceId
this.isMuted || unwrapConstraint(deviceId) === this._mediaStreamTrack.getSettings().deviceId
);
}

Expand Down

0 comments on commit cc65c84

Please sign in to comment.