core: Normalize negative seek positions

This reverts a change between 1.0 and 1.1, so no changelog.

Fixes #1180
This commit is contained in:
Stein Magnus Jodal 2015-07-22 12:14:04 +02:00
parent 131d992bed
commit 0ebfeb5a5b
2 changed files with 12 additions and 1 deletions

View File

@ -399,7 +399,12 @@ class PlaybackController(object):
:type time_position: int
:rtype: :class:`True` if successful, else :class:`False`
"""
validation.check_integer(time_position, min=0)
validation.check_integer(time_position)
if time_position < 0:
logger.debug(
'Client seeked to negative position. Seeking to zero.')
time_position = 0
if not self.core.tracklist.tracks:
return False

View File

@ -536,6 +536,12 @@ class CorePlaybackTest(unittest.TestCase):
self.assertFalse(self.playback1.seek.called)
self.playback2.seek.assert_called_once_with(10000)
def test_seek_normalizes_negative_positions_to_zero(self):
self.core.playback.play(self.tl_tracks[0])
self.core.playback.seek(-100)
self.playback1.seek.assert_called_once_with(0)
def test_seek_fails_for_unplayable_track(self):
self.set_current_tl_track(self.unplayable_tl_track)
self.core.playback.state = core.PlaybackState.PLAYING