[gnome-music/wip/jfelder/correct-play-artist: 2/2] albumwidget: Ensure that the correct album is played




commit 1f2b314982cef26bce45a94f9ad3d2ab116075fe
Author: Jean Felder <jfelder src gnome org>
Date:   Wed Nov 17 20:57:58 2021 +0100

    albumwidget: Ensure that the correct album is played
    
    When playing an album in artist view by clicking the play button, it
    always starts at the first album. This is because no coresong is
    requested: in that case, the first song of the first album is
    automatically loaded.
    
    This issue is fixed by loading the first song of the current album
    when the coreobject is an artist.
    
    Closes: https://gitlab.gnome.org/GNOME/gnome-music/-/issues/461

 gnomemusic/widgets/albumwidget.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index c553bd326..3c7e2a938 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -309,4 +309,12 @@ class AlbumWidget(Handy.Clamp):
 
     @Gtk.Template.Callback()
     def _on_play_button_clicked(self, button: Gtk.Button) -> None:
-        self._play()
+        # When the coreobject is an artist, the first song of the album
+        # needs to be loaded. Otherwise, the first album of the artist
+        # is played.
+        coresong: Optional[CoreSong] = None
+        if self.props.active_coreobject != self.props.corealbum:
+            coredisc = self.props.corealbum.props.model[0]
+            coresong = coredisc.props.model[0]
+
+        self._play(coresong)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]