Mark track as playing and add to history if changing track while paused.

This commit is contained in:
jcass 2015-12-06 16:01:26 +02:00
parent 22ec9d9060
commit 2b00e83179
3 changed files with 53 additions and 5 deletions

View File

@ -19,6 +19,9 @@ Bug fix release.
- MPD: Notify idling clients when a seek is performed. (Fixes: :issue:`1331`)
- Core: Fix error in :meth:`~mopidy.core.PlaybackController._change_track`
docstring. (Fixes: :issue:`1352`)
v1.1.1 (2015-09-14)
===================

View File

@ -207,12 +207,16 @@ 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.prepare_change().get and
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

View File

@ -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
@ -789,3 +789,44 @@ class Bug1177RegressionTest(unittest.TestCase):
c.playback.pause()
c.playback.next()
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])
d = mock.Mock()
c.history._add_track = d
e = mock.Mock()
c.tracklist._mark_playing = e
c.playback.play()
b.playback.change_track.reset_mock()
d.reset_mock()
e.reset_mock()
c.playback.pause()
c.playback.next()
b.playback.change_track.assert_called_once_with(track2)
d.assert_called_once_with(track2)
e.assert_called_once_with(tl_track2)