fix : play sound on move

This commit is contained in:
GuillaumeSD
2025-05-11 21:24:52 +02:00
parent 957cb3ce7a
commit 4a44aaf23e
2 changed files with 8 additions and 5 deletions

View File

@@ -6,11 +6,12 @@ let audio: HTMLAudioElement | null = null;
const playSound = async (url: string) => {
if (!audio) audio = new Audio();
const isPlaying = !audio.paused && !audio.ended;
if (isPlaying) return;
audio.src = url;
await audio.play();
try {
await audio.play();
} catch {
console.warn("Audio play failed");
}
};
export const playCaptureSound = () => playSound("/sounds/capture.webm");