From fb19efa72f631ab407cbf6e2cf124969d5492ec7 Mon Sep 17 00:00:00 2001 From: SlavaVlad Date: Mon, 15 Jun 2026 01:35:36 +0300 Subject: [PATCH] fix: howler unlock retry on playerror --- lib/sounds.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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) {