core: Remove unplayable track in consume mode

Fixes #1418

This was previously fixed in 1.1.2, but the fix was skipped in when
release-1.1 was merged into develop in #1400, thus no changelog entry.
This commit is contained in:
Stein Magnus Jodal 2016-02-14 15:22:25 +01:00
parent 0539e4e8fe
commit cc82e68a58
3 changed files with 16 additions and 1 deletions

View File

@ -346,7 +346,6 @@ class PlaybackController(object):
pending = tl_track or current or self.core.tracklist.next_track(None)
while pending:
# TODO: should we consume unplayable tracks in this loop?
if self._change(pending, PlaybackState.PLAYING):
break
else:

View File

@ -621,6 +621,8 @@ class TracklistController(object):
def _mark_unplayable(self, tl_track):
"""Internal method for :class:`mopidy.core.PlaybackController`."""
logger.warning('Track is not playable: %s', tl_track.track.uri)
if self.get_consume() and tl_track is not None:
self.remove({'tlid': [tl_track.tlid]})
if self.get_random() and tl_track in self._shuffled:
self._shuffled.remove(tl_track)

View File

@ -256,6 +256,20 @@ class TestConsumeHandling(BaseTest):
self.assertNotIn(tl_track, self.core.tracklist.get_tl_tracks())
def test_next_in_consume_mode_removes_unplayable_track(self):
last_playable_tl_track = self.core.tracklist.get_tl_tracks()[-2]
unplayable_tl_track = self.core.tracklist.get_tl_tracks()[-1]
self.audio.trigger_fake_playback_failure(unplayable_tl_track.track.uri)
self.core.playback.play(last_playable_tl_track)
self.core.tracklist.set_consume(True)
self.core.playback.next()
self.replay_events()
self.assertNotIn(
unplayable_tl_track, self.core.tracklist.get_tl_tracks())
def test_on_about_to_finish_in_consume_mode_removes_finished_track(self):
tl_track = self.core.tracklist.get_tl_tracks()[0]