From 0fd5298a313f8b899de845a0811a6d9429c3337d Mon Sep 17 00:00:00 2001 From: Erica Z Date: Sun, 20 Oct 2024 12:05:48 +0200 Subject: [PATCH] better cover art loading --- src/ui/window.vala | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/ui/window.vala b/src/ui/window.vala index d8cdc67..6abd063 100644 --- a/src/ui/window.vala +++ b/src/ui/window.vala @@ -67,26 +67,25 @@ class Ui.Window : Adw.ApplicationWindow { } this.cancel_loading_art = new GLib.Cancellable (); - if (this.song != null) { - this.cover_art_loading = true; + this.playing_cover_art = null; // TODO: preload next art somehow + this.cover_art_loading = true; - string song_id = this.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)); + string song_id = this.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; - } 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.playbin.stopped.connect (() => { - this.playing_cover_art = Gdk.Paintable.empty (1, 1); + this.playing_cover_art = null; this.song = null; });