Skip to content

Commit f10606d

Browse files
Merge pull request #254 from aunetx/josselinonduty/issue250
[BUG] MPRIS data is out-of-sync after app launch
2 parents 4660540 + 10cc2ba commit f10606d

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

patches/05-provide-metadata-mpris.patch

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ index a30f35a..e6efc46 100644
359359
break;
360360
}
361361
case "player-track-updated": {
362-
@@ -378,13 +433,49 @@
362+
@@ -378,13 +433,76 @@
363363
canRepeat: event.data.player.hasRepeat,
364364
canShuffle: event.data.player.hasShuffle,
365365
};
@@ -407,6 +407,33 @@ index a30f35a..e6efc46 100644
407407
+ }
408408
+ );
409409
+ }, 50),
410+
+ document.addEventListener("DOMContentLoaded", () => {
411+
+ if (!window.Events) return;
412+
+ let syncedSongId = null;
413+
+ const syncTrack = () => {
414+
+ const song = window.dzPlayer?.getCurrentSong?.();
415+
+ if (!song || song.SNG_ID === syncedSongId) return;
416+
+ syncedSongId = song.SNG_ID;
417+
+ renderer_ipc.send(
418+
+ "channel-player-track-update",
419+
+ {
420+
+ title:
421+
+ song.SNG_TITLE ||
422+
+ song.LIVESTREAM_TITLE ||
423+
+ song.EPISODE_TITLE ||
424+
+ "",
425+
+ artist:
426+
+ song.ART_NAME || song.LIVESTREAM_TITLE || song.SHOW_NAME || "",
427+
+ album: song.ALB_TITLE,
428+
+ coverUrl: `https://images.deezer.com/images/${song.SHOW_ART_MD5 ? "talk" : "cover"}/${song.ALB_PICTURE || song.SHOW_ART_MD5 || song.LIVESTREAM_IMAGE_MD5 || "d41d8cd98f00b204e9800998ecf8427e"}/250x250.jpg`,
429+
+ },
430+
+ {},
431+
+ { trackInfo: { song } }
432+
+ );
433+
+ };
434+
+ window.Events.ready(window.Events.player.playerReady, syncTrack);
435+
+ window.Events.subscribe(window.Events.player.tracklistReset, syncTrack);
436+
+ }),
410437
(function (layoutName, callback) {
411438
const layouts = nodeRequire("./assets/layout.json"),
412439
manifest = nodeRequire("./assets/manifest.json");

0 commit comments

Comments
 (0)