Deezer Media Session Support

Deezer Media Session Support for Chrome

目前为 2020-03-04 提交的版本。查看 最新版本

// ==UserScript==
// @name        Deezer Media Session Support
// @namespace   http://tampermonkey.net/
// @description    Deezer Media Session Support for Chrome
// @include     http://*.deezer.com/*
// @include     https://*.deezer.com/*
// @version     1.0
// @run-at      document-idle
// @noframes
// ==/UserScript==

//let dzPlayer = unsafeWindow.dzPlayer;
(function (dzPlayer, prevSongId){
	setInterval(function(currSong){
        currSong = dzPlayer.getCurrentSong();
		if (currSong.SNG_ID !== prevSongId){
			//dzPlayer.radioSkipCounter=1; // unlimited skips
			prevSongId = currSong.SNG_ID;
			navigator.mediaSession.metadata = new MediaMetadata({
				title: currSong.SNG_TITLE,
				artist: currSong.ART_NAME,
				album: currSong.ALB_TITLE,
				artwork: ['96x96','128x128','256x256','384x384','512x512'].map(function(size){
					return {'src': `https://e-cdns-images.dzcdn.net/images/cover/${currSong.ALB_PICTURE}/${size}-000000-80-0-0.jpg`,
						'sizes': size,
						'type': 'image/jpg'}
				})
			});
		}
	}, 500);

	navigator.mediaSession.setActionHandler('previoustrack', function() {
		if (!dzPlayer.isRadio()){
			dzPlayer.control.prevSong();
		}
	});

	navigator.mediaSession.setActionHandler('nexttrack', function() {
		dzPlayer.control.nextSong();
	});
})(dzPlayer, 0);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址