Skip to content Skip to sidebar Skip to footer

How Can I Show Media Controls For My Music Player Website In The Notification Tray Using Javascript/jquery?

As you know from the title that I want to customize the notification for my music player website. default chrome notification only contains play/pause button. is there any way I ca

Solution 1:

I think the API you are looking for is the Media Session API. If you register the handlers for the appropriate actions the browser should display buttons which trigger those handlers.

navigator.mediaSession.setActionHandler('previoustrack', () => {
    // Whatever you need to do to play the previous track.
});
navigator.mediaSession.setActionHandler('nexttrack', () => {
    // Whatever you need to do to play the next track.
});

Post a Comment for "How Can I Show Media Controls For My Music Player Website In The Notification Tray Using Javascript/jquery?"