Deezer Media Session Support for Chrome
当前为
// ==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.1
// @run-at document-idle
// @noframes
// ==/UserScript==
(function (dzPlayer, prevSongId){
setInterval(function(currSong){
currSong = dzPlayer.getCurrentSong();
if (currSong && 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);