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 can customize it to add buttons like next/previous or my own custom buttons.
I would like to implement javascript or Jquery for this.
Here is the website I am talking about.
Notification bar on mobile such as:
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.
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.