Skip to content

Commit

Permalink
Provide a last_currentsong method like last_status
Browse files Browse the repository at this point in the history
  • Loading branch information
eonpatapon committed Dec 31, 2012
1 parent 201727c commit bf6edc0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/mpDris2.in
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,17 @@ class MPDWrapper(mpd.MPDClient):
notification.rnotify(identity, _('Stopped'))
self.stop()

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

def last_status(self):
return self._status.copy()

def _update_properties(self):
old_status = self._status
old_position = self._position
old_time = self._time
self._currentsong = self.currentsong()
self._status = new_status = self.status()
self._time = new_time = int(time.time())

Expand Down Expand Up @@ -615,7 +619,7 @@ class MPRISInterface(dbus.service.Object):
return False

def __get_metadata():
return format_metadata(mpd_wrapper.currentsong())
return format_metadata(mpd_wrapper.last_currentsong())

def __get_volume():
vol = float(mpd_wrapper.last_status()['volume'])
Expand Down Expand Up @@ -780,7 +784,7 @@ class MPRISInterface(dbus.service.Object):

@dbus.service.method(__player_interface, in_signature='ox', out_signature='')
def SetPosition(self, trackid, position):
song = mpd_wrapper.currentsong()
song = self.last_currentsong()
# FIXME: use real dbus objects
if str(trackid) != '/org/mpris/MediaPlayer2/Track/%s' % song['id']:
return
Expand Down

0 comments on commit bf6edc0

Please sign in to comment.