From 3a598ffe43487f168d331a9a0df60dd9fe6aaddf Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 18 Jun 2026 11:35:46 +0200 Subject: [PATCH] Restore ability to play sound with custom volume This was missing from the revert in 8b0f5054ddd7d9446db24dcad432310306e4273d. --- src/room/GroupCallView.test.tsx | 2 +- src/useAudioContext.tsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/room/GroupCallView.test.tsx b/src/room/GroupCallView.test.tsx index 6d0612b89..a5c3b0d8e 100644 --- a/src/room/GroupCallView.test.tsx +++ b/src/room/GroupCallView.test.tsx @@ -310,7 +310,7 @@ test("Should close widget when all other left and play a sound", async () => { expect(widgetClosedCalled).toBeFalsy(); resolvePlaySound.resolve(); - expect(playSound).toHaveBeenCalledWith("left"); + expect(playSound).toHaveBeenCalledWith("left", 0); await widgetClosedPromise; await flushPromises(); expect(widgetClosedCalled).toBeTruthy(); diff --git a/src/useAudioContext.tsx b/src/useAudioContext.tsx index 4d08dde89..4a7c031ca 100644 --- a/src/useAudioContext.tsx +++ b/src/useAudioContext.tsx @@ -114,7 +114,7 @@ interface Props { } interface UseAudioContext { - playSound(soundName: S): Promise; + playSound(soundName: S, volumeOverwrite?: number): Promise; playSoundLooping(soundName: S, delayS?: number): () => Promise; /** * Map of sound name to duration in seconds. @@ -195,7 +195,7 @@ export function useAudioContext( } return { - playSound: async (name): Promise => { + playSound: async (name, volumeOverwrite?: number): Promise => { if (!audioBuffers[name]) { logger.debug(`Tried to play a sound that wasn't buffered (${name})`); return; @@ -203,7 +203,7 @@ export function useAudioContext( return playSound( audioContext, audioBuffers[name], - soundEffectVolume * earpieceVolume, + volumeOverwrite ?? soundEffectVolume * earpieceVolume, earpiecePan, ); },