demo · v137

Permission Allow

v137's default is to pause hidden-iframe audio. But the spec gates this on a Permissions Policy — media-playback-while-not-visible — so a parent that wants a hidden iframe to keep playing (music players, background mixers) can opt back in. Below: two identical iframes side by side, one with the permission, one without. Hide both and only one stays loud.

probing…

A. default (pauses when hidden)

<iframe srcdoc="..."></iframe>
awaiting tick…

B. allow="media-playback-while-not-visible"

<iframe allow="media-playback-while-not-visible" srcdoc="..."></iframe>
awaiting tick…

the code

<!-- Default: hidden -> AudioContext is suspended in Chrome 137+ -->
<iframe src="music-widget.html"></iframe>

<!-- Embedder opts in: hidden -> playback continues. -->
<iframe src="music-widget.html"
  allow="media-playback-while-not-visible"></iframe>

// Inside the iframe: nothing to change.
// document.featurePolicy.allowsFeature("media-playback-while-not-visible")
// can be polled to know which mode you are in.

see also