diff --git a/mopidy/backends/__init__.py b/mopidy/backends/__init__.py index 14b3a40b..f5317ac6 100644 --- a/mopidy/backends/__init__.py +++ b/mopidy/backends/__init__.py @@ -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 diff --git a/mopidy/backends/despotify.py b/mopidy/backends/despotify.py index 5bd3552b..11ad45c5 100644 --- a/mopidy/backends/despotify.py +++ b/mopidy/backends/despotify.py @@ -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'}) diff --git a/mopidy/core.py b/mopidy/core.py index 54d1e37b..acb3b984 100644 --- a/mopidy/core.py +++ b/mopidy/core.py @@ -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)