From 0f1bbec5dea61f0cc95957081158c3a36946aa51 Mon Sep 17 00:00:00 2001 From: Erica Z Date: Fri, 18 Oct 2024 22:17:04 +0200 Subject: [PATCH] instantly update next track info when manually switching --- src/playbin.vala | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/playbin.vala b/src/playbin.vala index a1b5e90..fd6a177 100644 --- a/src/playbin.vala +++ b/src/playbin.vala @@ -37,6 +37,8 @@ class Playbin : GLib.Object { public uint play_queue_position { get; private set; } public Subsonic.Song? song { get; private set; } + + private bool notify_next_playing; public signal void now_playing (); public double position { get; private set; default = 0.0; } @@ -126,8 +128,13 @@ class Playbin : GLib.Object { break; case Mpv.EventId.FILE_LOADED: - this.song = (Subsonic.Song) this.play_queue.get_item (this.play_queue_position); - this.now_playing (); + if (this.notify_next_playing) { + this.song = (Subsonic.Song) this.play_queue.get_item (this.play_queue_position); + this.now_playing (); + } else { + assert (this.song == (Subsonic.Song) this.play_queue.get_item (this.play_queue_position)); + this.notify_next_playing = true; + } break; case Mpv.EventId.END_FILE: @@ -159,6 +166,10 @@ class Playbin : GLib.Object { { assert (this.mpv.command ({"playlist-play-index", position.to_string ()}) >= 0); this.state = PlaybinState.PLAYING; + this.play_queue_position = position; + this.song = (Subsonic.Song) this.play_queue.get_item (position); + this.now_playing (); + this.notify_next_playing = false; } public void pause () {