如何使用javascript/jquery在通知托盘中显示音乐播放器网站的媒体控件? [英] how can i show media controls for my music player website in the notification tray using javascript/Jquery?

查看:54
本文介绍了如何使用javascript/jquery在通知托盘中显示音乐播放器网站的媒体控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从标题中可以知道,我想为我的音乐播放器网站自定义通知.默认的Chrome通知仅包含播放/暂停按钮.有什么方法可以自定义它以添加下一个/上一个按钮或我自己的自定义按钮.

我想为此实现javascript或jQuery.

这里是我正在谈论的谢谢您的支持.

解决方案

我认为您要查找的API是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.
});

这篇关于如何使用javascript/jquery在通知托盘中显示音乐播放器网站的媒体控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆