core: Move core.playback.on_end_of_track off change_track helper

Only handles the playing case, unlike the previous and next changes. It should
also be noted that this is just a temporary state on the road to making this
method handle gapless.
This commit is contained in:
Thomas Adamcik 2015-01-21 23:15:42 +01:00
parent 4a39671ee7
commit 82bf1c0eb9
2 changed files with 18 additions and 3 deletions

View File

@ -158,11 +158,25 @@ class PlaybackController(object):
original_tl_track = self.current_tl_track
next_tl_track = self.core.tracklist.eot_track(original_tl_track)
if next_tl_track:
self.change_track(next_tl_track)
backend = self._get_backend(next_tl_track)
self.current_tl_track = next_tl_track
if backend:
backend.playback.prepare_change()
backend.playback.change_track(next_tl_track.track)
result = backend.playback.play().get()
if result:
self.core.tracklist.mark_playing(next_tl_track)
self.core.history.add(next_tl_track.track)
# TODO: replace with stream-changed
self._trigger_track_playback_started()
else:
self.core.tracklist.mark_unplayable(next_tl_track)
# TODO: can cause an endless loop for single track repeat.
self.next()
else:
self.stop()
self.current_tl_track = None
self.core.tracklist.mark_played(original_tl_track)

View File

@ -350,6 +350,7 @@ class CorePlaybackTest(unittest.TestCase):
self.assertNotIn(tl_track, self.core.tracklist.tl_tracks)
@unittest.skip('Currently tests wrong events, and nothing generates them.')
@mock.patch(
'mopidy.core.playback.listener.CoreListener', spec=core.CoreListener)
def test_on_end_of_track_emits_events(self, listener_mock):