MPD: Handle 'play "-1"' in same way as 'playid "-1"'
This commit is contained in:
parent
b408751520
commit
c8b6e4728d
@ -839,6 +839,7 @@ class MpdFrontend(object):
|
||||
raise MpdAckError(e[0])
|
||||
|
||||
@handle_pattern(r'^play "(?P<songpos>\d+)"$')
|
||||
@handle_pattern(r'^play "(?P<songpos>-1)"$')
|
||||
def _playback_playpos(self, songpos):
|
||||
"""
|
||||
*musicpd.org, playback section:*
|
||||
@ -846,10 +847,17 @@ class MpdFrontend(object):
|
||||
``play [SONGPOS]``
|
||||
|
||||
Begins playing the playlist at song number ``SONGPOS``.
|
||||
|
||||
*MPoD:*
|
||||
|
||||
- issues ``play "-1"`` after playlist replacement.
|
||||
"""
|
||||
songpos = int(songpos)
|
||||
try:
|
||||
track = self.backend.current_playlist.playlist.tracks[songpos]
|
||||
if songpos == -1:
|
||||
track = self.backend.current_playlist.playlist.tracks[0]
|
||||
else:
|
||||
track = self.backend.current_playlist.playlist.tracks[songpos]
|
||||
return self.backend.playback.play(track)
|
||||
except IndexError:
|
||||
raise MpdAckError(u'Position out of bounds')
|
||||
|
||||
@ -461,6 +461,14 @@ class PlaybackControlHandlerTest(unittest.TestCase):
|
||||
self.assert_(u'ACK Position out of bounds' in result)
|
||||
self.assertEqual(self.b.playback.STOPPED, self.b.playback.state)
|
||||
|
||||
def test_play_minus_one_plays_first_in_playlist(self):
|
||||
track = Track(id=0)
|
||||
self.b.current_playlist.load(Playlist(tracks=[track]))
|
||||
result = self.h.handle_request(u'play "-1"')
|
||||
self.assert_(u'OK' in result)
|
||||
self.assertEqual(self.b.playback.PLAYING, self.b.playback.state)
|
||||
self.assertEqual(self.b.playback.current_track, track)
|
||||
|
||||
def test_playid(self):
|
||||
self.b.current_playlist.load(Playlist(tracks=[Track(id=0)]))
|
||||
result = self.h.handle_request(u'playid "0"')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user