fix: howler unlock retry on playerror
Some checks failed
Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Deploy / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user