diff --git a/src/ui/window.vala b/src/ui/window.vala index 3fe17d1..6ba084d 100644 --- a/src/ui/window.vala +++ b/src/ui/window.vala @@ -57,6 +57,29 @@ class Ui.Window : Adw.ApplicationWindow { this.playbin.now_playing.connect (() => { api.scrobble.begin (playbin.song.id); this.play_queue.selection.playbin_select (playbin.play_queue_position); + + if (this.cancel_loading_art != null) { + this.cancel_loading_art.cancel (); + } + this.cancel_loading_art = new GLib.Cancellable (); + + this.playing_cover_art = Gdk.Paintable.empty (1, 1); + if (playbin.song != null) { + this.cover_art_loading = true; + + string song_id = playbin.song.id; + this.api.cover_art.begin (song_id, this.cancel_loading_art, (obj, res) => { + try { + this.playing_cover_art = Gdk.Texture.for_pixbuf (this.api.cover_art.end (res)); + this.cover_art_loading = false; + } catch (Error e) { + if (!(e is IOError.CANCELLED)) { + warning ("could not load cover for %s: %s", song_id, e.message); + this.cover_art_loading = false; + } + } + }); + } }); this.play_queue.selection.user_selected.connect ((position) => { @@ -84,31 +107,6 @@ class Ui.Window : Adw.ApplicationWindow { this.setup.load (); this.sidebar.select_row (this.sidebar.get_row_at_index (0)); - - this.playbin.notify["current-song"].connect (() => { - if (this.cancel_loading_art != null) { - this.cancel_loading_art.cancel (); - } - this.cancel_loading_art = new GLib.Cancellable (); - - this.playing_cover_art = Gdk.Paintable.empty (1, 1); - if (playbin.song != null) { - this.cover_art_loading = true; - - string song_id = playbin.song.id; - this.api.cover_art.begin (song_id, this.cancel_loading_art, (obj, res) => { - try { - this.playing_cover_art = Gdk.Texture.for_pixbuf (this.api.cover_art.end (res)); - this.cover_art_loading = false; - } catch (Error e) { - if (!(e is IOError.CANCELLED)) { - warning ("could not load cover for %s: %s", song_id, e.message); - this.cover_art_loading = false; - } - } - }); - } - }); } [GtkCallback] private void on_sidebar_row_activated (Gtk.ListBoxRow row) {