From 77f47b2a0e9b1513601406780f7145facb0cb03a Mon Sep 17 00:00:00 2001 From: lukasIO Date: Fri, 3 Nov 2023 17:24:42 +0200 Subject: [PATCH] Correctly apply elementVolume on attach for webaudioMix --- src/room/track/RemoteAudioTrack.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/room/track/RemoteAudioTrack.ts b/src/room/track/RemoteAudioTrack.ts index 2b011eca28..9bb5ab1a71 100644 --- a/src/room/track/RemoteAudioTrack.ts +++ b/src/room/track/RemoteAudioTrack.ts @@ -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); @@ -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; }