如何在 Google Chrome 中启用或禁用全局媒体控件
请参阅“全球媒体控制”
- 转到 chrome://flags/#global-media-controls
- 设置“启用”
- 单击“重新启动”按钮
如何在 Google Chrome 中自定义(背景图片、点击操作)全局媒体控件
例子:
if ('mediaSession' in navigator) {
navigator.mediaSession.metadata = new MediaMetadata({
title: "TITLE",
artist: "ARTIST",
album: "ALBUM",
artwork: [{
sizes: "320x180",// <- MUST BE EXACTLY!
src: "https://i.ytimg.com/vi/yAruCvT7P7Y/hqdefault.jpg?sqp=-oaymwEZCNACELwBSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLAfHWw5BHrQugGsdPYy4eIXcqMTnQ",
type: ""
}]
});
navigator.mediaSession.setActionHandler('play', function () { });
navigator.mediaSession.setActionHandler('pause', function () { });
navigator.mediaSession.setActionHandler('seekbackward', function () { });
navigator.mediaSession.setActionHandler('seekforward', function () { });
navigator.mediaSession.setActionHandler('previoustrack', function () { });
navigator.mediaSession.setActionHandler('nexttrack', function () { });
}