Add 'play -1' support, which fixes resume in MPoD

This commit is contained in:
Stein Magnus Jodal 2011-02-12 01:45:36 +01:00
parent 04f8276ffb
commit 15c992e06a
3 changed files with 30 additions and 7 deletions

View File

@ -19,6 +19,8 @@ No description yet.
commands. This makes media library browsing in ncmpcpp work, though very
slow due to all the meta data requests to Spotify.
- Add support for ``play "-1"``, which fixes resume in MPoD.
- Settings:
- Fix crash on ``--list-settings`` on clean installation. Thanks to Martins

View File

@ -132,10 +132,13 @@ def playid(frontend, cpid):
Begins playing the playlist at song ``SONGID``.
*GMPC:*
*Clarifications:*
- issues ``playid "-1"`` after playlist replacement to start playback
at the first track.
- ``playid "-1"`` when paused resumes playback.
- ``playid "-1"`` when stopped with a current track starts playback at the
current track.
- ``playid "-1"`` when stopped without a current track, e.g. after playlist
replacement, starts playback at the first track.
"""
cpid = int(cpid)
paused = (frontend.backend.playback.state ==
@ -161,17 +164,23 @@ def playpos(frontend, songpos):
Begins playing the playlist at song number ``SONGPOS``.
*Many clients:*
*Clarifications:*
- issue ``play "-1"`` after playlist replacement to start the current
track. If the current track is not set, start playback at the first
track.
- ``playid "-1"`` when paused resumes playback.
- ``playid "-1"`` when stopped with a current track starts playback at the
current track.
- ``playid "-1"`` when stopped without a current track, e.g. after playlist
replacement, starts playback at the first track.
*BitMPC:*
- issues ``play 6`` without quotes around the argument.
"""
songpos = int(songpos)
paused = (frontend.backend.playback.state ==
frontend.backend.playback.PAUSED)
if songpos == -1 and paused:
return frontend.backend.playback.resume()
try:
if songpos == -1:
cp_track = _get_cp_track_for_play_minus_one(frontend)

View File

@ -257,6 +257,18 @@ class PlaybackControlHandlerTest(unittest.TestCase):
self.assertEqual(self.b.playback.STOPPED, self.b.playback.state)
self.assertEqual(self.b.playback.current_track, None)
def test_play_minus_one_resumes_if_paused(self):
self.b.current_playlist.append([Track(length=40000)])
self.b.playback.seek(30000)
self.assert_(self.b.playback.time_position >= 30000)
self.assertEquals(self.b.playback.PLAYING, self.b.playback.state)
self.b.playback.pause()
self.assertEquals(self.b.playback.PAUSED, self.b.playback.state)
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.assert_(self.b.playback.time_position >= 30000)
def test_playid(self):
self.b.current_playlist.append([Track()])
result = self.h.handle_request(u'playid "0"')