diff --git a/src/playbin.vala b/src/playbin.vala index 50cb31a..0b4819b 100644 --- a/src/playbin.vala +++ b/src/playbin.vala @@ -40,6 +40,7 @@ class Playbin : GLib.Object { private bool notify_next_playing; public signal void now_playing (); + public signal void stopped (); public double position { get; private set; default = 0.0; } public double duration { get; private set; default = 0.0; } @@ -114,16 +115,16 @@ class Playbin : GLib.Object { case 2: assert (data.name == "playlist-pos"); - if (data.format == Mpv.Format.NONE) { + if (data.parse_int64 () < 0) { + debug ("playlist-pos is null, sending stopped event"); this.play_queue_position = this.play_queue.get_n_items (); + this.song = null; + this.state = PlaybinState.STOPPED; + this.stopped (); } else { - if (data.parse_int64 () < 0) { - this.play_queue_position = this.play_queue.get_n_items (); - } else { - this.play_queue_position = (uint) data.parse_int64 (); - } + this.play_queue_position = (uint) data.parse_int64 (); + debug (@"playlist-pos has been updated to $(this.play_queue_position)"); } - debug (@"playlist-pos has been updated to $(this.play_queue_position)"); break; default: diff --git a/src/ui/window.vala b/src/ui/window.vala index bfd3e42..a5b5e42 100644 --- a/src/ui/window.vala +++ b/src/ui/window.vala @@ -82,6 +82,10 @@ class Ui.Window : Adw.ApplicationWindow { } }); + this.playbin.stopped.connect (() => { + this.playing_cover_art = Gdk.Paintable.empty (1, 1); + }); + this.play_queue.selection.user_selected.connect ((position) => { this.playbin.select_track (position); });