[gnome-music/wip/mschraal/artrework: 4/6] player: Fix MPRIS2 coverart update
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/artrework: 4/6] player: Fix MPRIS2 coverart update
- Date: Wed, 31 Jan 2018 15:16:53 +0000 (UTC)
commit 18d5efa3b09700cdc69edebe1e2b66f154f6366e
Author: Marinus Schraal <mschraal gnome org>
Date: Mon Jan 29 09:59:43 2018 +0100
player: Fix MPRIS2 coverart update
Pass a signal between Art, CoverArt, Player and MediaPlayer2Service that
coverart is ready.
gnomemusic/albumartcache.py | 13 +++++++++++++
gnomemusic/player.py | 4 ++--
gnomemusic/widgets/coverstack.py | 6 ++++++
3 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/albumartcache.py b/gnomemusic/albumartcache.py
index 120de93..f9d0239 100644
--- a/gnomemusic/albumartcache.py
+++ b/gnomemusic/albumartcache.py
@@ -227,6 +227,7 @@ class Art(GObject.GObject):
def _cache_hit(self, klass, pixbuf):
surface = _make_icon_frame(pixbuf, self._size, self._scale)
self._surface = surface
+ self._set_grilo_thumbnail_path()
self.emit('finished')
@@ -286,6 +287,18 @@ class Art(GObject.GObject):
return False
+ def _set_grilo_thumbnail_path(self):
+ # TODO: This sets the thumbnail path for the Grilo Media object
+ # to be used by MPRIS. However, calling this by default for
+ # every cache hit is unnecessary.
+ album = utils.get_album_title(self._media)
+ artist = utils.get_artist_name(self._media)
+
+ success, thumb_file = MediaArt.get_file(artist, album, "album")
+ if success:
+ self._media.set_thumbnail(
+ GLib.filename_to_uri(thumb_file.get_path(), None))
+
@GObject.Property
@log
def surface(self):
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 40becc9..ebc8b15 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -633,8 +633,7 @@ class Player(GObject.GObject):
return False
@log
- def _on_cache_lookup(self, surface, data=None):
- # FIXME: Need this for mpris
+ def _on_cover_stack_updated(self, klass):
self.emit('thumbnail-updated')
@log
@@ -778,6 +777,7 @@ class Player(GObject.GObject):
stack = self._ui.get_object('cover')
self._cover_stack = CoverStack(stack, Art.Size.XSMALL)
+ self._cover_stack.connect('updated', self._on_cover_stack_updated)
self.duration = self._ui.get_object('duration')
self.repeatBtnImage = self._ui.get_object('playlistRepeat')
diff --git a/gnomemusic/widgets/coverstack.py b/gnomemusic/widgets/coverstack.py
index c5f623f..fda824f 100644
--- a/gnomemusic/widgets/coverstack.py
+++ b/gnomemusic/widgets/coverstack.py
@@ -36,6 +36,10 @@ class CoverStack(GObject.GObject):
or in between songs.
"""
+ __gsignals__ = {
+ 'updated': (GObject.SignalFlags.RUN_FIRST, None, ())
+ }
+
_default_icon = DefaultIcon()
@log
@@ -85,3 +89,5 @@ class CoverStack(GObject.GObject):
else:
self._cover_b.set_from_surface(klass.surface)
self._stack.set_visible_child_name("B")
+
+ self.emit('updated')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]