Move play state from SpotifyBackend to BaseBackend
This commit is contained in:
parent
18f2f01236
commit
837ef248d9
@ -1,5 +1,11 @@
|
||||
|
||||
class BaseBackend(object):
|
||||
PLAY = u'play'
|
||||
PAUSE = u'pause'
|
||||
STOP = u'stop'
|
||||
|
||||
def __init__(self):
|
||||
self.state = self.STOP
|
||||
|
||||
def current_song(self):
|
||||
return None
|
||||
|
||||
@ -29,7 +35,7 @@ class BaseBackend(object):
|
||||
return 0
|
||||
|
||||
def status_state(self):
|
||||
return 'stop'
|
||||
return self.state
|
||||
|
||||
# Control methods
|
||||
def stop(self):
|
||||
|
||||
@ -8,10 +8,6 @@ from mopidy.backends.base import BaseBackend
|
||||
|
||||
logger = logging.getLogger(u'backends.spotify')
|
||||
|
||||
PLAY = u'play'
|
||||
PAUSE = u'pause'
|
||||
STOP = u'stop'
|
||||
|
||||
def encode(string):
|
||||
return string.encode('utf-8')
|
||||
|
||||
@ -21,7 +17,6 @@ def decode(string):
|
||||
class SpotifyBackend(BaseBackend):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SpotifyBackend, self).__init__(*args, **kwargs)
|
||||
self.mode = STOP
|
||||
logger.info(u'Connecting to Spotify')
|
||||
self.spotify = spytify.Spytify(self._username, self._password)
|
||||
logger.info(u'Preloading data')
|
||||
@ -96,11 +91,11 @@ class SpotifyBackend(BaseBackend):
|
||||
|
||||
def current_song(self):
|
||||
track = self.spotify.current_track
|
||||
if track is not None and self.mode in (PLAY, PAUSE):
|
||||
if track is not None and self.state in (self.PLAY, self.PAUSE):
|
||||
return self._format_track(track)
|
||||
|
||||
def play_id(self, songid):
|
||||
self.mode = PLAY
|
||||
self.state = self.PLAY
|
||||
track = self._current_playlist[songid]
|
||||
self.spotify.play(track)
|
||||
|
||||
@ -131,7 +126,7 @@ class SpotifyBackend(BaseBackend):
|
||||
return self._format_playlist(self._current_playlist)
|
||||
|
||||
def stop(self):
|
||||
self.mode = STOP
|
||||
self.state = self.STOP
|
||||
self.spotify.stop()
|
||||
|
||||
def status_playlist(self):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user