Riff / Built on the open web / Media
Page Visibility
Moves a playing video to audio when the page goes to the background.

How Riff uses it
When the page is hidden while a video is playing, the handler flips the track to the audio element and remembers it did. When the page is visible again it flips back. The same event restarts the per-frame seek follower, and the loops check document.hidden so they stop in the background.
Why
A phone pauses video in the background but keeps audio going, so backgrounding a tab during a video would otherwise stop the music.
Where
- plugins/riff/assets/riff.js, line 373
document.addEventListener( 'visibilitychange', () => {
Links open the source at the commit this page was published from.
Reference: Page Visibility on MDN.