MPD: Improve seek impl and add seekid impl. Add tests which fails.

This commit is contained in:
Stein Magnus Jodal 2010-08-14 14:10:44 +02:00
parent da2a44fd17
commit abcc9c1007
3 changed files with 14 additions and 3 deletions

View File

@ -46,6 +46,7 @@ greatly improved MPD client support.
``single`` without quotes to work better with BitMPC.
- Fixed delete current playing track from playlist, which crashed several
clients.
- Implement ``seek`` and ``seekid``.
- Backends:

View File

@ -293,6 +293,8 @@ def seek(frontend, songpos, seconds):
Seeks to the position ``TIME`` (in seconds) of entry ``SONGPOS`` in
the playlist.
"""
if frontend.backend.playback.current_playlist_position != songpos:
playpos(frontend, songpos)
return frontend.backend.playback.seek(int(seconds) * 1000)
@handle_pattern(r'^seekid "(?P<cpid>\d+)" "(?P<seconds>\d+)"$')
@ -304,7 +306,9 @@ def seekid(frontend, cpid, seconds):
Seeks to the position ``TIME`` (in seconds) of song ``SONGID``.
"""
raise MpdNotImplemented # TODO
if frontend.backend.playback.current_cpid != cpid:
playid(frontend, cpid)
return frontend.backend.playback.seek(int(seconds) * 1000)
@handle_pattern(r'^setvol "(?P<volume>[-+]*\d+)"$')
def setvol(frontend, volume):

View File

@ -271,12 +271,18 @@ class PlaybackControlHandlerTest(unittest.TestCase):
self.assert_(u'OK' in result)
def test_seek(self):
self.b.current_playlist.load([Track()])
self.h.handle_request(u'seek "0"')
result = self.h.handle_request(u'seek "0" "30"')
self.assert_(u'ACK [0@0] {} Not implemented' in result)
self.assert_(u'OK' in result)
self.assert_(self.b.playback.time_position > 30000)
def test_seekid(self):
self.b.current_playlist.load([Track()])
result = self.h.handle_request(u'seekid "0" "30"')
self.assert_(u'ACK [0@0] {} Not implemented' in result)
self.assert_(u'OK' in result)
self.assert_(self.b.playback.time_position > 30000)
def test_stop(self):
result = self.h.handle_request(u'stop')