fix: howler unlock retry on playerror
Some checks failed
Deploy / build-and-deploy (push) Has been cancelled

This commit is contained in:
2026-06-15 01:35:36 +03:00
parent 05c4f19109
commit fb19efa72f

View File

@@ -130,6 +130,7 @@ export function playSoundUrl(url: string) {
}, },
onplayerror: (_id: number, err: unknown) => { onplayerror: (_id: number, err: unknown) => {
console.error("[BaraBingo] Howl play error:", url, err); console.error("[BaraBingo] Howl play error:", url, err);
h.once("unlock", () => h.play());
}, },
}); });
howlCache.set(url, h); 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. * Useful for preview/editor buttons where you want it to play every click.
*/ */
export function playSoundOnce(url: string) { export function playSoundOnce(url: string) {
new Howl({ const h = new Howl({
src: [url], src: [url],
format: url.endsWith(".mp3") ? ["mp3"] : url.endsWith(".ogg") ? ["ogg"] : ["mp3", "ogg"], format: url.endsWith(".mp3") ? ["mp3"] : url.endsWith(".ogg") ? ["ogg"] : ["mp3", "ogg"],
volume: 0.4, volume: 0.4,
@@ -151,8 +152,11 @@ export function playSoundOnce(url: string) {
}, },
onplayerror: (_id: number, err: unknown) => { onplayerror: (_id: number, err: unknown) => {
console.error("[BaraBingo] Howl play error:", url, err); 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) { export function playSound(category: string, soundUrl?: string | null) {