fix: add state to pause existing audio for demo menus, add support fo… (#10428)

This commit is contained in:
Joseph Campuzano
2026-01-24 12:16:53 -06:00
committed by GitHub
parent 32e6bcae3b
commit 15801a01ba
3 changed files with 35 additions and 7 deletions

View File

@@ -106,5 +106,12 @@ export function soundSrc(id: string | undefined) {
export function playSound(src: string | undefined) {
if (typeof Audio === "undefined") return
if (!src) return
void new Audio(src).play().catch(() => undefined)
const audio = new Audio(src)
audio.play().catch(() => undefined)
// Return a cleanup function to pause the sound.
return () => {
audio.pause()
audio.currentTime = 0
}
}