Skip to content

Commit

Permalink
Correctly apply elementVolume on attach for webaudioMix (#922)
Browse files Browse the repository at this point in the history
* Correctly apply elementVolume on attach for webaudioMix

* Create dirty-parrots-kneel.md
  • Loading branch information
lukasIO committed Nov 3, 2023
1 parent 89557f4 commit c833637
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-parrots-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Correctly apply elementVolume on attach for webaudioMix
10 changes: 7 additions & 3 deletions src/room/track/RemoteAudioTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ export default class RemoteAudioTrack extends RemoteTrack {
} else {
super.attach(element);
}
if (this.elementVolume) {
element.volume = this.elementVolume;
}

if (this.sinkId && supportsSetSinkId(element)) {
/* @ts-ignore */
element.setSinkId(this.sinkId);
Expand All @@ -114,6 +112,12 @@ export default class RemoteAudioTrack extends RemoteTrack {
element.volume = 0;
element.muted = true;
}

if (this.elementVolume) {
// make sure volume setting is being applied to the newly attached element
this.setVolume(this.elementVolume);
}

return element;
}

Expand Down

0 comments on commit c833637

Please sign in to comment.