From b1fe053de2e2d8d7014f50dd2d1125583a393852 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 3 Nov 2010 08:11:57 +0100 Subject: mpclient: new signal that's emitted when current song's position changes --- nephilim/mpclient.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nephilim/mpclient.py b/nephilim/mpclient.py index 8badbcb..5263ccd 100644 --- a/nephilim/mpclient.py +++ b/nephilim/mpclient.py @@ -109,6 +109,7 @@ class MPClient(QtCore.QObject): db_updated = Signal() time_changed = Signal(int) song_changed = Signal(object) + songpos_changed = Signal(object) # this one's emitted when only current song's position changed state_changed = Signal(str) volume_changed = Signal(int) repeat_changed = Signal(bool) @@ -460,6 +461,7 @@ class MPClient(QtCore.QObject): pass if 'playlist' in subsystems: self.playlist_changed.emit() + self._command('currentsong', callback = self._update_cur_song) if 'output' in subsystems: self._command('outputs', callback = self._update_outputs) @@ -508,11 +510,15 @@ class MPClient(QtCore.QObject): self._command('currentsong', callback = self._update_cur_song) def _update_cur_song(self, data): + song = self.cur_song try: self.cur_song = Song(list(self._parse_objects(data, ''))[0]) except IndexError: self.cur_song = Song() - self.song_changed.emit(self.cur_song) + if song['id'] != self.cur_song['id']: + self.song_changed.emit(self.cur_song) + else: + self.songpos_changed.emit(self.cur_song) def _command(self, *cmd, **kwargs): """ -- cgit v1.2.3