Don't change to playing state when seeking in paused state

Do not switch state from paused to playing when seeking
This commit is contained in:
Lasse Bigum 2015-03-01 15:19:12 +01:00
parent 47911f24ea
commit fbd534efbf
4 changed files with 37 additions and 9 deletions

View File

@ -33,6 +33,9 @@ v0.20.0 (UNRELEASED)
- Add :meth:`mopidy.core.LibraryController.get_images` for looking up images
for any URI backends know about. (Fixes :issue:`973`)
- When seeking in paused state, do not change to playing state. (Fixed
:issue:`939`)
**Commands**
- Make the ``mopidy`` command print a friendly error message if the

View File

@ -371,8 +371,6 @@ class PlaybackController(object):
if self.get_state() == PlaybackState.STOPPED:
self.play()
elif self.get_state() == PlaybackState.PAUSED:
self.resume()
if time_position < 0:
time_position = 0

View File

@ -85,6 +85,25 @@ class CorePlaybackTest(unittest.TestCase):
'track_playback_started', tl_track=self.tl_tracks[0]),
])
@mock.patch(
'mopidy.core.playback.listener.CoreListener', spec=core.CoreListener)
def test_play_when_paused_emits_events(self, listener_mock):
self.core.playback.play(self.tl_tracks[0])
self.core.playback.pause()
listener_mock.reset_mock()
self.core.playback.play(self.tl_tracks[1])
self.assertListEqual(
listener_mock.send.mock_calls,
[
mock.call(
'playback_state_changed',
old_state='paused', new_state='playing'),
mock.call(
'track_playback_started', tl_track=self.tl_tracks[1]),
])
@mock.patch(
'mopidy.core.playback.listener.CoreListener', spec=core.CoreListener)
def test_play_when_playing_emits_events(self, listener_mock):
@ -389,6 +408,20 @@ class CorePlaybackTest(unittest.TestCase):
self.assertFalse(self.playback1.seek.called)
self.assertFalse(self.playback2.seek.called)
def test_seek_play_stay_playing(self):
self.core.playback.play(self.tl_tracks[0])
self.core.playback.state = core.PlaybackState.PLAYING
self.core.playback.seek(1000)
self.assertEqual(self.core.playback.state, core.PlaybackState.PLAYING)
def test_seek_paused_stay_paused(self):
self.core.playback.play(self.tl_tracks[0])
self.core.playback.state = core.PlaybackState.PAUSED
self.core.playback.seek(1000)
self.assertEqual(self.core.playback.state, core.PlaybackState.PAUSED)
@mock.patch(
'mopidy.core.playback.listener.CoreListener', spec=core.CoreListener)
def test_seek_emits_seeked_event(self, listener_mock):

View File

@ -798,6 +798,7 @@ class LocalPlaybackProviderTest(unittest.TestCase):
self.playback.pause()
result = self.playback.seek(self.tracks[0].length - 1000)
self.assert_(result, 'Seek return value was %s' % result)
self.assertEqual(self.playback.state, PlaybackState.PAUSED)
@populate_tracklist
def test_seek_when_paused_updates_position(self):
@ -808,13 +809,6 @@ class LocalPlaybackProviderTest(unittest.TestCase):
position = self.playback.time_position
self.assertGreaterEqual(position, length - 1010)
@populate_tracklist
def test_seek_when_paused_triggers_play(self):
self.playback.play()
self.playback.pause()
self.playback.seek(0)
self.assertEqual(self.playback.state, PlaybackState.PLAYING)
@unittest.SkipTest
@populate_tracklist
def test_seek_beyond_end_of_song(self):