From cc7ed79a90a546e84d439753a433b517587861fc Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Thu, 5 Dec 2024 11:07:44 +0000 Subject: [PATCH] Remove another debug line. --- src/useAudioContext.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/useAudioContext.tsx b/src/useAudioContext.tsx index 4212bf7d..e61954b6 100644 --- a/src/useAudioContext.tsx +++ b/src/useAudioContext.tsx @@ -24,21 +24,21 @@ type SoundDefinition = { mp3?: string; ogg: string }; * @param volume The volume to play at. * @param ctx The context to play through. * @param buffer The buffer to play. + * @returns A promise that resolves when the sound has stopped playing. */ -function playSound( +async function playSound( ctx: AudioContext, buffer: AudioBuffer, volume: number, -): void { - if (!ctx || !buffer) { - return; - } +): Promise { + logger.debug("Playing back sound"); const gain = ctx.createGain(); gain.gain.setValueAtTime(volume, 0); const src = ctx.createBufferSource(); src.buffer = buffer; src.connect(gain).connect(ctx.destination); src.start(); + return new Promise((r) => src.addEventListener("ended", () => r())); } /** @@ -163,7 +163,6 @@ export function useAudioContext( // Don't return a function until we're ready. if (!audioContext || !audioBuffers) { - logger.debug("Audio not ready yet"); return null; } return {