diff --git a/Engine/src/shared/audio.ts b/Engine/src/shared/audio.ts index e55e0b6..5c56093 100644 --- a/Engine/src/shared/audio.ts +++ b/Engine/src/shared/audio.ts @@ -88,16 +88,21 @@ export function playSong(name: string) { } } -export function playSound(name: string): HTMLAudioElement { +export function playSound(name: string, volume: number): HTMLAudioElement { let s = new Audio() if (!enabled) return s s.src = audio[name] + s.volume = volume s.autoplay = true s.preload = '' - ;(async () => { - await s.play() - })() + let promise = s.play() + if (promise !== undefined) { + promise.then(() => { + // ok + }).catch((error: any) => { + }) + } return s } \ No newline at end of file