mirror of
https://github.com/vector-im/element-call.git
synced 2026-07-15 18:49:21 +00:00
Restore ability to play sound with custom volume
This was missing from the revert in 8b0f5054dd.
This commit is contained in:
@@ -310,7 +310,7 @@ test("Should close widget when all other left and play a sound", async () => {
|
|||||||
expect(widgetClosedCalled).toBeFalsy();
|
expect(widgetClosedCalled).toBeFalsy();
|
||||||
resolvePlaySound.resolve();
|
resolvePlaySound.resolve();
|
||||||
|
|
||||||
expect(playSound).toHaveBeenCalledWith("left");
|
expect(playSound).toHaveBeenCalledWith("left", 0);
|
||||||
await widgetClosedPromise;
|
await widgetClosedPromise;
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
expect(widgetClosedCalled).toBeTruthy();
|
expect(widgetClosedCalled).toBeTruthy();
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ interface Props<S extends string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface UseAudioContext<S extends string> {
|
interface UseAudioContext<S extends string> {
|
||||||
playSound(soundName: S): Promise<void>;
|
playSound(soundName: S, volumeOverwrite?: number): Promise<void>;
|
||||||
playSoundLooping(soundName: S, delayS?: number): () => Promise<void>;
|
playSoundLooping(soundName: S, delayS?: number): () => Promise<void>;
|
||||||
/**
|
/**
|
||||||
* Map of sound name to duration in seconds.
|
* Map of sound name to duration in seconds.
|
||||||
@@ -195,7 +195,7 @@ export function useAudioContext<S extends string>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
playSound: async (name): Promise<void> => {
|
playSound: async (name, volumeOverwrite?: number): Promise<void> => {
|
||||||
if (!audioBuffers[name]) {
|
if (!audioBuffers[name]) {
|
||||||
logger.debug(`Tried to play a sound that wasn't buffered (${name})`);
|
logger.debug(`Tried to play a sound that wasn't buffered (${name})`);
|
||||||
return;
|
return;
|
||||||
@@ -203,7 +203,7 @@ export function useAudioContext<S extends string>(
|
|||||||
return playSound(
|
return playSound(
|
||||||
audioContext,
|
audioContext,
|
||||||
audioBuffers[name],
|
audioBuffers[name],
|
||||||
soundEffectVolume * earpieceVolume,
|
volumeOverwrite ?? soundEffectVolume * earpieceVolume,
|
||||||
earpiecePan,
|
earpiecePan,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user