Skip to content

Instantly share code, notes, and snippets.

@gotbahn
Created March 7, 2020 13:08
Show Gist options
  • Save gotbahn/d04661f2607e6e89ed82608fb6dda69e to your computer and use it in GitHub Desktop.
Save gotbahn/d04661f2607e6e89ed82608fb6dda69e to your computer and use it in GitHub Desktop.
Media Session. Next & Previous
// to add playlist action handlers
if (/* has playlist */) {
window.navigator.mediasSession.setActionHandler('nexttrack', () => { /* your next item */ });
window.navigator.mediasSession.setActionHandler('previoustrack', () => { /* your previous item */ });
}
// to cancel playlist action handlers
window.navigator.mediasSession.setActionHandler('nexttrack', null);
window.navigator.mediasSession.setActionHandler('previoustrack', null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment