Skip to content

Commit

Permalink
Merge branch 'master' into repl-usability
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc authored Dec 2, 2021
2 parents 6e71969 + 4d176eb commit a57828a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/mpDris2.in.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,9 @@ def mediakey_callback(self, appname, key):
self.notify_about_state('stop')

def last_currentsong(self):
return self._currentsong.copy()
if self._currentsong:
return self._currentsong.copy()
return None

@property
def metadata(self):
Expand All @@ -507,9 +509,13 @@ def update_metadata(self):
http://www.freedesktop.org/wiki/Specifications/mpris-spec/metadata
"""

mpd_meta = self.last_currentsong()
self._metadata = {}

mpd_meta = self.last_currentsong()
if not mpd_meta:
logger.warning("Attempted to update metadata, but retrieved none")
return

for tag in ('album', 'title'):
if tag in mpd_meta:
self._metadata['xesam:%s' % tag] = mpd_meta[tag]
Expand Down Expand Up @@ -1227,6 +1233,10 @@ def Seek(self, offset):
@dbus.service.method(__player_interface, in_signature='ox', out_signature='')
def SetPosition(self, trackid, position):
song = MPRISInterface.__wrapper.last_currentsong()
song = mpd_wrapper.last_currentsong()
if not song:
logger.error("Failed to retrieve song position, can't seek")
return()
# FIXME: use real dbus objects
if str(trackid) != '/org/mpris/MediaPlayer2/Track/%s' % song['id']:
return
Expand Down

0 comments on commit a57828a

Please sign in to comment.