From 51df14521bdd7f173423c75ba78dcf8a69b0c8ff Mon Sep 17 00:00:00 2001 From: you Date: Sun, 22 Mar 2026 17:27:54 +0000 Subject: [PATCH] Audio: create context eagerly on restore, gesture listener as fallback --- public/audio.js | 6 ++++-- public/index.html | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/public/audio.js b/public/audio.js index e573b19d..e59eed98 100644 --- a/public/audio.js +++ b/public/audio.js @@ -175,10 +175,12 @@ const savedVoice = localStorage.getItem('live-audio-voice'); if (savedVoice) setVoice(savedVoice); - // If audio was enabled, wait for ANY user gesture to init context + // If audio was enabled, create context now and try to resume. + // Browsers with prior engagement will auto-allow; gesture listener is fallback. if (audioEnabled) { + initAudio(); const unlockAudio = () => { - initAudio(); + if (audioCtx && audioCtx.state === 'suspended') audioCtx.resume(); document.removeEventListener('click', unlockAudio, true); document.removeEventListener('touchstart', unlockAudio, true); document.removeEventListener('keydown', unlockAudio, true); diff --git a/public/index.html b/public/index.html index 8e639bf5..4af7268d 100644 --- a/public/index.html +++ b/public/index.html @@ -90,7 +90,7 @@ - +