MPD: Improve seek impl and add seekid impl. Add tests which fails.
This commit is contained in:
parent
da2a44fd17
commit
abcc9c1007
@ -46,6 +46,7 @@ greatly improved MPD client support.
|
|||||||
``single`` without quotes to work better with BitMPC.
|
``single`` without quotes to work better with BitMPC.
|
||||||
- Fixed delete current playing track from playlist, which crashed several
|
- Fixed delete current playing track from playlist, which crashed several
|
||||||
clients.
|
clients.
|
||||||
|
- Implement ``seek`` and ``seekid``.
|
||||||
|
|
||||||
- Backends:
|
- Backends:
|
||||||
|
|
||||||
|
|||||||
@ -293,6 +293,8 @@ def seek(frontend, songpos, seconds):
|
|||||||
Seeks to the position ``TIME`` (in seconds) of entry ``SONGPOS`` in
|
Seeks to the position ``TIME`` (in seconds) of entry ``SONGPOS`` in
|
||||||
the playlist.
|
the playlist.
|
||||||
"""
|
"""
|
||||||
|
if frontend.backend.playback.current_playlist_position != songpos:
|
||||||
|
playpos(frontend, songpos)
|
||||||
return frontend.backend.playback.seek(int(seconds) * 1000)
|
return frontend.backend.playback.seek(int(seconds) * 1000)
|
||||||
|
|
||||||
@handle_pattern(r'^seekid "(?P<cpid>\d+)" "(?P<seconds>\d+)"$')
|
@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``.
|
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+)"$')
|
@handle_pattern(r'^setvol "(?P<volume>[-+]*\d+)"$')
|
||||||
def setvol(frontend, volume):
|
def setvol(frontend, volume):
|
||||||
|
|||||||
@ -271,12 +271,18 @@ class PlaybackControlHandlerTest(unittest.TestCase):
|
|||||||
self.assert_(u'OK' in result)
|
self.assert_(u'OK' in result)
|
||||||
|
|
||||||
def test_seek(self):
|
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"')
|
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):
|
def test_seekid(self):
|
||||||
|
self.b.current_playlist.load([Track()])
|
||||||
result = self.h.handle_request(u'seekid "0" "30"')
|
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):
|
def test_stop(self):
|
||||||
result = self.h.handle_request(u'stop')
|
result = self.h.handle_request(u'stop')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user