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 () {