The audio context to keep running
Detach function removing all listeners
Attaches capture-phase pointerdown/keydown listeners on the
document that call resume() while the context is suspended, plus a
visibilitychange listener that retries when the page returns to the
foreground. Listeners are passive with respect to audio scheduling —
this only wakes the context so that sounds triggered by app logic
(timers, remote events, MIDI input) are audible once the user has
interacted with the page at least once.
Safe to call in any environment; outside the browser it is a no-op. Attach once per context and call the returned detach function when the context is closed or the owning component unmounts.
Keep an audio context running across the two ways mobile browsers silently suspend it: created-before-first-gesture, and re-suspended after backgrounding or an audio-session interruption.