Skip to content

Instantly share code, notes, and snippets.

@gotbahn
Last active March 31, 2020 11:48
Show Gist options
  • Save gotbahn/290e816ea50962c245c924dd19d79580 to your computer and use it in GitHub Desktop.
Save gotbahn/290e816ea50962c245c924dd19d79580 to your computer and use it in GitHub Desktop.
Media Session. Play & pause action handlers
// to set action handlers
window.navigator.mediasSession.setActionHandler('play', () => { /* your play */ });
window.navigator.mediasSession.setActionHandler('pause', () => { /* your pause */ });
// to reset action handlers
window.navigator.mediasSession.setActionHandler('play', null);
window.navigator.mediasSession.setActionHandler('pause', null);
// handlers like action & pause have defaults, to cancel them you can use noop function
window.navigator.mediasSession.setActionHandler('play', () => {});
window.navigator.mediasSession.setActionHandler('pause', () => {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment