fix: TypeScript - capture Howl ref in closure
All checks were successful
Deploy / build-and-deploy (push) Successful in 1m52s
All checks were successful
Deploy / build-and-deploy (push) Successful in 1m52s
This commit is contained in:
@@ -121,7 +121,7 @@ const howlCache = new Map<string, Howl>();
|
||||
export function playSoundUrl(url: string) {
|
||||
let h = howlCache.get(url);
|
||||
if (!h) {
|
||||
h = new Howl({
|
||||
const newH = new Howl({
|
||||
src: [url],
|
||||
format: url.endsWith(".mp3") ? ["mp3"] : url.endsWith(".ogg") ? ["ogg"] : ["mp3", "ogg"],
|
||||
volume: 0.4,
|
||||
@@ -130,10 +130,11 @@ export function playSoundUrl(url: string) {
|
||||
},
|
||||
onplayerror: (_id: number, err: unknown) => {
|
||||
console.error("[BaraBingo] Howl play error:", url, err);
|
||||
h.once("unlock", () => h.play());
|
||||
newH.once("unlock", () => newH.play());
|
||||
},
|
||||
});
|
||||
howlCache.set(url, h);
|
||||
howlCache.set(url, newH);
|
||||
h = newH;
|
||||
}
|
||||
h.play();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user