mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
asyncify
This commit is contained in:
@@ -26,7 +26,7 @@ type SoundDefinition = { mp3?: string; ogg: string };
|
|||||||
* @param buffer The buffer to play.
|
* @param buffer The buffer to play.
|
||||||
* @returns A promise that resolves when the sound has finished playing.
|
* @returns A promise that resolves when the sound has finished playing.
|
||||||
*/
|
*/
|
||||||
function playSound(
|
async function playSound(
|
||||||
ctx: AudioContext,
|
ctx: AudioContext,
|
||||||
buffer: AudioBuffer,
|
buffer: AudioBuffer,
|
||||||
volume: number,
|
volume: number,
|
||||||
@@ -100,7 +100,7 @@ interface Props<S extends string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface UseAudioContext<S> {
|
interface UseAudioContext<S> {
|
||||||
playSound(soundName: S): void;
|
playSound(soundName: S): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -166,7 +166,7 @@ export function useAudioContext<S extends string>(
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
playSound: (name): Promise<void> => {
|
playSound: async (name): 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;
|
||||||
|
|||||||
Reference in New Issue
Block a user