diff --git a/lib/sounds.ts b/lib/sounds.ts index 9083662..c449d43 100644 --- a/lib/sounds.ts +++ b/lib/sounds.ts @@ -130,6 +130,7 @@ export function playSoundUrl(url: string) { }, onplayerror: (_id: number, err: unknown) => { console.error("[BaraBingo] Howl play error:", url, err); + h.once("unlock", () => h.play()); }, }); howlCache.set(url, h); @@ -142,7 +143,7 @@ export function playSoundUrl(url: string) { * Useful for preview/editor buttons where you want it to play every click. */ export function playSoundOnce(url: string) { - new Howl({ + const h = new Howl({ src: [url], format: url.endsWith(".mp3") ? ["mp3"] : url.endsWith(".ogg") ? ["ogg"] : ["mp3", "ogg"], volume: 0.4, @@ -151,8 +152,11 @@ export function playSoundOnce(url: string) { }, onplayerror: (_id: number, err: unknown) => { console.error("[BaraBingo] Howl play error:", url, err); + // On play error (e.g. AudioContext suspended), unlock and retry + h.once("unlock", () => h.play()); }, - }).play(); + }); + h.play(); } export function playSound(category: string, soundUrl?: string | null) {