diff --git a/docs/changelog.rst b/docs/changelog.rst index 7637de58..41d5cccc 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -19,6 +19,10 @@ Bug fix release. - MPD: Notify idling clients when a seek is performed. (Fixes: :issue:`1331`) +- Core: Fix bug in playback controller. If changing to another track while + the player is paused, the new track would not be added to the history or + marked as currently playing. (Fixes: :issue:`1352`) + v1.1.1 (2015-09-14) =================== diff --git a/mopidy/core/playback.py b/mopidy/core/playback.py index 9a11066b..eeba5106 100644 --- a/mopidy/core/playback.py +++ b/mopidy/core/playback.py @@ -207,12 +207,15 @@ class PlaybackController(object): if old_state == PlaybackState.PLAYING: self._play(on_error_step=on_error_step) elif old_state == PlaybackState.PAUSED: - # NOTE: this is just a quick hack to fix #1177 as this code has - # already been killed in the gapless branch. + # NOTE: this is just a quick hack to fix #1177 and #1352 as this + # code has already been killed in the gapless branch. backend = self._get_backend() if backend: backend.playback.prepare_change() - backend.playback.change_track(tl_track.track).get() + success = backend.playback.change_track(tl_track.track).get() + if success: + self.core.tracklist._mark_playing(tl_track) + self.core.history._add_track(tl_track.track) self.pause() # TODO: this is not really end of track, this is on_need_next_track diff --git a/tests/core/test_playback.py b/tests/core/test_playback.py index 5fab9f6b..d176db0b 100644 --- a/tests/core/test_playback.py +++ b/tests/core/test_playback.py @@ -8,7 +8,7 @@ import pykka from mopidy import backend, core from mopidy.internal import deprecation -from mopidy.models import Track +from mopidy.models import TlTrack, Track from tests import dummy_audio as audio @@ -808,6 +808,43 @@ class Bug1177RegressionTest(unittest.TestCase): b.playback.change_track.assert_called_once_with(track2) +class Bug1352RegressionTest(unittest.TestCase): + def test(self): + config = { + 'core': { + 'max_tracklist_length': 10000, + } + } + + b = mock.Mock() + b.uri_schemes.get.return_value = ['dummy'] + b.playback = mock.Mock(spec=backend.PlaybackProvider) + b.playback.change_track.return_value.get.return_value = True + b.playback.play.return_value.get.return_value = True + + track1 = Track(uri='dummy:a', length=40000) + track2 = Track(uri='dummy:b', length=40000) + + tl_track2 = TlTrack(1, track2) + + c = core.Core(config, mixer=None, backends=[b]) + c.tracklist.add([track1, track2]) + + c.history._add_track = mock.PropertyMock() + c.tracklist._mark_playing = mock.PropertyMock() + + c.playback.play() + b.playback.change_track.reset_mock() + c.history._add_track.reset_mock() + c.tracklist._mark_playing.reset_mock() + + c.playback.pause() + c.playback.next() + b.playback.change_track.assert_called_once_with(track2) + c.history._add_track.assert_called_once_with(track2) + c.tracklist._mark_playing.assert_called_once_with(tl_track2) + + class Bug1358RegressionTest(unittest.TestCase): def setUp(self): # noqa: N802