diff --git a/src/lib/player_object.py b/src/lib/player_object.py
index 7f17026..44c5e7e 100644
--- a/src/lib/player_object.py
+++ b/src/lib/player_object.py
@@ -149,6 +149,17 @@ def _play_track(self, track):
self.playing_track = track
self.song_album = track.album
+
+ if len(self.tracks_to_play) > 0:
+ self.can_next = True
+ else:
+ self.can_next = False
+
+ if len(self.played_songs) > 0:
+ self.can_prev = True
+ else:
+ self.can_prev = False
+
self.emit("song-changed")
def play_next(self):
diff --git a/src/mpris.py b/src/mpris.py
index 380114d..f3864a9 100644
--- a/src/mpris.py
+++ b/src/mpris.py
@@ -144,13 +144,13 @@ def __init__(self, player, window):
self.__metadata["mpris:trackid"] = GLib.Variant(
"o", f"/Track/{track_id}"
)
- self.__metadata["xesam:title"] = GLib.Variant(
- "s", "Prova"
- )
- self.__metadata["xesam:album"] = GLib.Variant(
- "s", _("Album")
- )
- self.__metadata["xesam:artist"] = GLib.Variant("as", [_("Artist")])
+
+ track = self.player.playing_track
+
+ if track:
+ self.__metadata["xesam:title"] = GLib.Variant("s", track.name)
+ self.__metadata["xesam:album"] = GLib.Variant("s", track.album)
+ self.__metadata["xesam:artist"] = GLib.Variant("as", [track.artist])
self.__bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
Gio.bus_own_name_on_connection(
@@ -158,8 +158,8 @@ def __init__(self, player, window):
)
Server.__init__(self, self.__bus, self.__MPRIS_PATH)
- # MainPlayer.get().connect("preset-changed", self._on_preset_changed)
- # MainPlayer.get().connect("notify::playing", self._on_playing_changed)
+ self.player.connect("song-changed", self._on_preset_changed)
+ self.player.connect("play-changed", self._on_playing_changed)
# MainPlayer.get().connect("notify::volume", self._on_volume_changed)
def Raise(self):
@@ -263,19 +263,23 @@ def _get_status(self):
return "Paused"
def _on_preset_changed(self, *args):
- self.__metadata["xesam:title"] = GLib.Variant("s", "Prova?")
+ self.__metadata["xesam:title"] = GLib.Variant("s", self.player.playing_track.name)
+ self.__metadata["xesam:album"] = GLib.Variant("s", self.player.playing_track.album.name)
+ self.__metadata["xesam:artist"] = GLib.Variant("as", [self.player.playing_track.artist.name])
+ self.__metadata["xesam:artUrl"] = GLib.Variant("s", f"tmp_img/{self.player.playing_track.album.id}.jpg")
+
changed_properties = {
"Metadata": GLib.Variant("a{sv}", self.__metadata),
- "CanGoNext": GLib.Variant("b", True),
- "CanGoPrevious": GLib.Variant("b", True),
+ "CanGoNext": GLib.Variant("b", self.player.can_next),
+ "CanGoPrevious": GLib.Variant("b", self.player.can_prev),
}
self.PropertiesChanged(self.__MPRIS_PLAYER_IFACE, changed_properties, [])
- def _on_volume_changed(self, player, volume):
+ def _on_volume_changed(self, _player, volume):
self.PropertiesChanged(
self.__MPRIS_PLAYER_IFACE,
{
- "Volume": GLib.Variant("d", MainPlayer.get().volume),
+ "Volume": GLib.Variant("d", self.player.volume),
},
[],
)
diff --git a/src/ui/pages_ui/tracks_list_template.ui b/src/ui/pages_ui/tracks_list_template.ui
index 707c479..a047089 100644
--- a/src/ui/pages_ui/tracks_list_template.ui
+++ b/src/ui/pages_ui/tracks_list_template.ui
@@ -136,6 +136,7 @@
@@ -143,6 +144,7 @@