Riff / Built on the open web / Media
Media Session
Gives the lock screen and headphones the track's title, artwork and controls.

How Riff uses it
Each new track builds a MediaMetadata with title, artist, album and every artwork size. Eight action handlers map the system's play, pause, previous, next, seek and stop onto the player's own functions. The playing state and position are mirrored, position at most once a second.
Why
Without it the lock screen, headphones and the system media widget would show a blank page title and could not skip tracks.
Without it
Guarded by feature checks and a try/catch per action, so the on-page controls are the only controls.
Where
- plugins/riff/assets/riff.js, line 1321
navigator.mediaSession.metadata = new window.MediaMetadata( { - plugins/riff/assets/riff.js, line 1382
navigator.mediaSession.setActionHandler( action, handler ); - plugins/riff/assets/riff.js, line 1347
navigator.mediaSession.setPositionState( {
Links open the source at the commit this page was published from.
Reference: Media Session on MDN.