Add 'play' command which starts the last played track
This commit is contained in:
parent
9cec5ef768
commit
1f967b3213
@ -50,6 +50,9 @@ class BaseBackend(object):
|
||||
def pause(self):
|
||||
self.state = self.PAUSE
|
||||
|
||||
def play(self):
|
||||
self.state = self.PLAY
|
||||
|
||||
def play_pos(self, songpos):
|
||||
self.state = self.PLAY
|
||||
|
||||
|
||||
@ -116,6 +116,9 @@ class SpotifyBackend(BaseBackend):
|
||||
self.state = self.PAUSE
|
||||
self.spotify.pause()
|
||||
|
||||
def play(self):
|
||||
self.play_id(self._current_song_id)
|
||||
|
||||
def play_pos(self, songpos):
|
||||
self.play_id(songpos)
|
||||
|
||||
|
||||
@ -227,8 +227,12 @@ class MpdHandler(object):
|
||||
def _ping(self):
|
||||
pass
|
||||
|
||||
@register(r'^play$')
|
||||
def _play(self):
|
||||
return self.backend.play()
|
||||
|
||||
@register(r'^play "(?P<songpos>\d+)"$')
|
||||
def _play(self, songpos):
|
||||
def _playpos(self, songpos):
|
||||
return self.backend.play_pos(int(songpos))
|
||||
|
||||
@register(r'^playid "(?P<songid>\d+)"$')
|
||||
|
||||
@ -257,7 +257,12 @@ class PlaybackControlHandlerTest(unittest.TestCase):
|
||||
self.assert_(u'OK' in result)
|
||||
self.assertEquals(self.b.PAUSE, self.b.state)
|
||||
|
||||
def test_play(self):
|
||||
def test_play_without_pos(self):
|
||||
result = self.h.handle_request(u'play')
|
||||
self.assert_(u'OK' in result)
|
||||
self.assertEquals(self.b.PLAY, self.b.state)
|
||||
|
||||
def test_play_with_pos(self):
|
||||
result = self.h.handle_request(u'play "0"')
|
||||
self.assert_(u'OK' in result)
|
||||
self.assertEquals(self.b.PLAY, self.b.state)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user