简体   繁体   中英

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 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:

在此处输入图像描述 Thank You for any of your support.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM