fix gapless playback handling

This commit is contained in:
uh wot 2024-05-31 20:39:43 +02:00
parent e7c610f089
commit 96f7b1e646
Signed by: uhwot
GPG Key ID: CB2454984587B781
1 changed files with 6 additions and 2 deletions

View File

@ -3,7 +3,7 @@
// @namespace io.github.uhwot.dzunlock // @namespace io.github.uhwot.dzunlock
// @description enables deezer hifi features lol // @description enables deezer hifi features lol
// @author uh wot // @author uh wot
// @version 1.4.3 // @version 1.4.4
// @license GPL-3.0-only // @license GPL-3.0-only
// @homepageURL https://git.uhwot.cf/uhwot/dzunlock // @homepageURL https://git.uhwot.cf/uhwot/dzunlock
// @downloadURL https://uhwotgit.fly.dev/uhwot/dzunlock/raw/branch/master/dzunlock.user.js // @downloadURL https://uhwotgit.fly.dev/uhwot/dzunlock/raw/branch/master/dzunlock.user.js
@ -137,16 +137,20 @@ unsafeWindow.WebSocket = new Proxy(unsafeWindow.WebSocket, {
} }
}) })
let last_track_id = null
unsafeWindow.fetch = (function (fetch) { unsafeWindow.fetch = (function (fetch) {
return async function (url, init) { return async function (url, init) {
if (url === 'https://media.deezer.com/v1/get_url') { if (url === 'https://media.deezer.com/v1/get_url') {
let track let track
if (unsafeWindow.dzPlayer.getPosition() === 0) { if (last_track_id !== unsafeWindow.dzPlayer.getSongId()) {
track = unsafeWindow.dzPlayer.getCurrentSong() track = unsafeWindow.dzPlayer.getCurrentSong()
} else { } else {
track = unsafeWindow.dzPlayer.getNextSong() // gapless playback track = unsafeWindow.dzPlayer.getNextSong() // gapless playback
} }
last_track_id = track.SNG_ID
const quality = unsafeWindow.dzPlayer.control.getAudioQuality() const quality = unsafeWindow.dzPlayer.control.getAudioQuality()
const id = parseInt(track.SNG_ID) const id = parseInt(track.SNG_ID)