Merge branch 'master' into gstreamer
This commit is contained in:
commit
c612edd205
@ -549,6 +549,10 @@ class BasePlaybackController(object):
|
||||
self.current_track = track
|
||||
self.state = self.PLAYING
|
||||
|
||||
# TODO Do something sensible when _play() returns False, like calling
|
||||
# next(). Adding this todo instead of just implementing it as I want a
|
||||
# test case first.
|
||||
|
||||
if self.random and self.current_track in self._shuffled:
|
||||
self._shuffled.remove(self.current_track)
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ import os
|
||||
import multiprocessing
|
||||
import threading
|
||||
|
||||
from spotify import Link
|
||||
from spotify import Link, SpotifyError
|
||||
from spotify.manager import SpotifySessionManager
|
||||
from spotify.alsahelper import AlsaController
|
||||
|
||||
@ -63,6 +63,10 @@ class LibspotifyCurrentPlaylistController(BaseCurrentPlaylistController):
|
||||
|
||||
|
||||
class LibspotifyLibraryController(BaseLibraryController):
|
||||
def lookup(self, uri):
|
||||
spotify_track = Link.from_string(uri).as_track()
|
||||
return LibspotifyTranslator.to_mopidy_track(spotify_track)
|
||||
|
||||
def search(self, type, what):
|
||||
if type is u'any':
|
||||
query = what
|
||||
@ -90,10 +94,14 @@ class LibspotifyPlaybackController(BasePlaybackController):
|
||||
self.stop()
|
||||
if track.uri is None:
|
||||
return False
|
||||
self.backend.spotify.session.load(
|
||||
Link.from_string(track.uri).as_track())
|
||||
self.backend.spotify.session.play(1)
|
||||
return True
|
||||
try:
|
||||
self.backend.spotify.session.load(
|
||||
Link.from_string(track.uri).as_track())
|
||||
self.backend.spotify.session.play(1)
|
||||
return True
|
||||
except SpotifyError as e:
|
||||
logger.warning('Play %s failed: %s', track.uri, e)
|
||||
return False
|
||||
|
||||
def _resume(self):
|
||||
# TODO
|
||||
|
||||
@ -780,6 +780,14 @@ class BasePlaybackControllerTest(object):
|
||||
tracks = self.backend.current_playlist.playlist.tracks
|
||||
self.assert_(self.tracks[0] not in tracks)
|
||||
|
||||
@populate_playlist
|
||||
def test_playlist_is_empty_after_all_tracks_are_played_with_consume(self):
|
||||
self.playback.consume = True
|
||||
self.playback.play()
|
||||
for i in range(len(self.backend.current_playlist.playlist.tracks)):
|
||||
self.playback.next()
|
||||
self.assertEqual(len(self.backend.current_playlist.playlist.tracks), 0)
|
||||
|
||||
@populate_playlist
|
||||
def test_play_with_random(self):
|
||||
random.seed(1)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user