Add end_of_track supportto despotify

This commit is contained in:
Stein Magnus Jodal 2010-03-20 01:20:51 +01:00
parent aa8b67a327
commit be76965282
3 changed files with 10 additions and 2 deletions

View File

@ -388,6 +388,10 @@ class BasePlaybackController(object):
def volume(self, volume):
self.backend.mixer.volume = volume
def end_of_track_callback(self):
"""Tell the playback controller that end of track is reached."""
self.next()
def new_playlist_loaded_callback(self):
"""Tell the playback controller that a new playlist has been loaded."""
self.current_track = None

View File

@ -53,7 +53,8 @@ class DespotifyBackend(BaseBackend):
logger.info(u'Connecting to Spotify')
return DespotifySessionManager(
settings.SPOTIFY_USERNAME.encode(ENCODING),
settings.SPOTIFY_PASSWORD.encode(ENCODING))
settings.SPOTIFY_PASSWORD.encode(ENCODING),
core_queue=self.core_queue)
class DespotifyCurrentPlaylistController(BaseCurrentPlaylistController):
@ -164,9 +165,10 @@ class DespotifySessionManager(spytify.Spytify):
def __init__(self, *args, **kwargs):
kwargs['callback'] = self.callback
self.core_queue = kwargs.pop('core_queue')
super(DespotifySessionManager, self).__init__(*args, **kwargs)
def callback(self, signal, data):
if signal == self.DESPOTIFY_END_OF_PLAYLIST:
logger.debug('Despotify signalled end of playlist')
# TODO Ask backend to play next track
self.core_queue.put({'command': 'end_of_track'})

View File

@ -19,5 +19,7 @@ class CoreProcess(multiprocessing.Process):
response = frontend.handle_request(message['request'])
connection = unpickle_connection(message['reply_to'])
connection.send(response)
elif message['command'] == 'end_of_track':
backend.playback.end_of_track_callback()
else:
logger.warning(u'Cannot handle message: %s', message)