Merge pull request #1534 from edran/fix-scrobbling

Get correct track position on change events
This commit is contained in:
Thomas Adamcik 2016-07-25 22:05:34 +02:00
parent 692138a51e
commit 44ff669744
2 changed files with 14 additions and 0 deletions

View File

@ -29,6 +29,10 @@ Bug fix release.
- Core: Avoid endless loop if all tracks in the tracklist are unplayable and
consume mode is off. (Fixes: :issue:`1221`, :issue:`1454`, PR: :issue:`1455`)
- Core: Correctly record the last position of a track when switching to another
one. Particularly relevant for `mopidy-scrobbler` users, as before it was
essentially unusable. (Fixes: :issue:`1456`, PR: :issue:`1534`)
- File: Ensure path comparision is done between bytestrings only. Fixes crash
where a :confval:`file/media_dirs` path contained non-ASCII characters.
(Fixes: :issue:`1345`, PR: :issue:`1493`)

View File

@ -251,6 +251,12 @@ class PlaybackController(object):
if self._state == PlaybackState.STOPPED:
return
# Unless overridden by other calls (e.g. next / previous / stop) this
# will be the last position recorded until the track gets reassigned.
# TODO: Check if case when track.length isn't populated needs to be
# handled.
self._last_position = self._current_tl_track.track.length
pending = self.core.tracklist.eot_track(self._current_tl_track)
# avoid endless loop if 'repeat' is 'true' and no track is playable
# * 2 -> second run to get all playable track in a shuffled playlist
@ -394,6 +400,10 @@ class PlaybackController(object):
if not backend:
return False
# This must happen before prepare_change gets called, otherwise the
# backend flushes the information of the track.
self._last_position = self.get_time_position()
# TODO: Wrap backend call in error handling.
backend.playback.prepare_change()