v136 · multimedia
AudioContext Interrupted State
The current Web Audio API lacks a mechanism for the User Agent (UA) to interrupt playback for scenarios such as exclusive audio access (VoIP) or when a laptop lid is closed. To address this, we propose adding an "interrupted" state to AudioContextState. This new state would allow the UA to pause playback in these scenarios and enable web applications to resp
concepts
-
interrupted State
AudioContext gains an interrupted state for OS-level audio interruptions (phone calls, focus loss). Sites can surface 'paused by system' UX cleanly.
-
VoIP-style pause & resume
Live Web Audio tone player: distinguishes
interrupted(OS pulled focus — "paused by system") fromsuspended(user paused), with optional auto-resume strategy when focus returns. -
State Machine Visualiser
The full set of
AudioContextStatetransitions on one screen:suspended ↔ running ↔ interruptedplus the terminalclosed. Buttons drive each legal call, the diagram lights up the active node, and everystatechangeis timestamped. -
Screen share coordinator
A simulated recording app that responds to the
interruptedstate correctly: stops recording, shows "interrupted by system" banner, auto-resumes when focus returns — and distinguishes that from a user-triggeredsuspendedwhich should NOT auto-resume.
why it shipped
Currently, there is no way for the User Agent (UA) to interrupt a Web Audio API AudioContext playback on its own - i.e., the suspension must happen in response to a user action. There are scenarios where the UA must be able to interrupt audio playback on its own: - Interrupt an AudioContext when another application requires exclusive access to audio hardware; - Audio Session API (https://w3c.github.io/audio-session/) - "media-playback-while-not-visible" permission policy (https://chromestatus.com/feature/5082950457884672)