navigator.mediaSession.metadata = new MediaMetadata({
title: song.name,
album: song.category,
artwork: [{src: song.imagePath, type: 'image/jpg'}]
})
navigator.mediaSession.setActionHandler('play', player.play)
navigator.mediaSession.setActionHandler('pause', player.pause)
navigator.mediaSession.setActionHandler('nexttrack', player.nextTrack)
navigator.mediaSession.setActionHandler('previoustrack', player.prevTrack)
// song and player are instances of state
Then you get those native media controls. Even stuff like "hey google, play/pause/skip"Try using Spotify's mobile web app for an example. Works great.