fix(audio): handle spamming play
This commit is contained in:
@@ -7,17 +7,14 @@ type Rect = [number, number, number, number];
|
|||||||
let atlasImage: HTMLImageElement | null = null;
|
let atlasImage: HTMLImageElement | null = null;
|
||||||
const modelCache = new Map<string, THREE.Group>();
|
const modelCache = new Map<string, THREE.Group>();
|
||||||
|
|
||||||
const createAudio = (path: string) => {
|
const createAudio = (path: string) => ({
|
||||||
const audio = import.meta.client ? new Audio(path) : null;
|
|
||||||
|
|
||||||
return {
|
|
||||||
play: () => {
|
play: () => {
|
||||||
if (!audio) return;
|
if (!import.meta.client) return;
|
||||||
audio.currentTime = 0;
|
const audio = new Audio(path);
|
||||||
|
audio.addEventListener("ended", () => audio.remove(), { once: true });
|
||||||
audio.play().catch(() => {});
|
audio.play().catch(() => {});
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
};
|
|
||||||
|
|
||||||
const loaded = ref(0);
|
const loaded = ref(0);
|
||||||
const total = ref({{TOTAL}});
|
const total = ref({{TOTAL}});
|
||||||
|
|||||||
Reference in New Issue
Block a user