From 4af6de5329024ac252c08130187212da3df366a6 Mon Sep 17 00:00:00 2001 From: Pihkaal Date: Tue, 24 Feb 2026 17:51:55 +0100 Subject: [PATCH] fix(audio): handle spamming play --- app/composables/useAssets.ts.in | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/app/composables/useAssets.ts.in b/app/composables/useAssets.ts.in index a5eaa90..5c92b6b 100644 --- a/app/composables/useAssets.ts.in +++ b/app/composables/useAssets.ts.in @@ -7,17 +7,14 @@ type Rect = [number, number, number, number]; let atlasImage: HTMLImageElement | null = null; const modelCache = new Map(); -const createAudio = (path: string) => { - const audio = import.meta.client ? new Audio(path) : null; - - return { +const createAudio = (path: string) => ({ play: () => { - if (!audio) return; - audio.currentTime = 0; + if (!import.meta.client) return; + const audio = new Audio(path); + audio.addEventListener("ended", () => audio.remove(), { once: true }); audio.play().catch(() => {}); }, - }; -}; +}); const loaded = ref(0); const total = ref({{TOTAL}});