From f812dcdefbdf091384c8973d2d7b5f3aa19f852a Mon Sep 17 00:00:00 2001 From: coderkun Date: Fri, 22 Jun 2012 16:42:48 +0200 Subject: [PATCH] MCGClient: play command implemented --- mcg.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/mcg.py b/mcg.py index f54a599..5d323ff 100644 --- a/mcg.py +++ b/mcg.py @@ -190,6 +190,7 @@ class MCGClient: track = MCGTrack(song['title'], song['track'], song['time'], song['file']) album.add_track(track) + count += 1 except KeyError: pass # TODO Alben sortieren @@ -199,8 +200,12 @@ class MCGClient: def _play(self, album): """Action: Performs the real play command. """ - # TODO _play() - pass + track_ids = [] + for track in self._albums[album].get_tracks(): + track_id = self._client.addid(track.get_file()) + track_ids.append(track_id) + self._client.moveid(track_id, len(track_ids)-1) + self._client.playid(track_ids[0]) def _idle(self, modules): @@ -230,10 +235,18 @@ class MCGClient: status = self._client.status() state = status['state'] song = self._client.currentsong() - album = MCGAlbum(song['artist'], song['album'], song['date'], os.path.dirname(song['file'])) + album = None + if song: + album = MCGAlbum(song['artist'], song['album'], song['date'], os.path.dirname(song['file'])) self._callback(self.SIGNAL_IDLE_PLAYER, state, album) + def _idle_playlist(self): + """ Reacts on the playlist idle event. + """ + pass + + class MCGAlbum: