Skip to content

Commit

Permalink
Merge pull request #1534 from edran/fix-scrobbling
Browse files Browse the repository at this point in the history
Get correct track position on change events
  • Loading branch information
adamcik committed Jul 25, 2016
2 parents 57b8b84 + 6e603a1 commit 5b6632e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ Bug fix release.
remains unimplemented. (PR: :issue:`1520`)

- MPD: Add ``nextsong`` and ``nextsongid`` to the response of MPD ``status`` command.
(Fixes: :issue:`1133` :issue:`1516`, PR: :issue:`1523`)
(Fixes: :issue:`1133`, :issue:`1516`, PR: :issue:`1523`)

- 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`)


v2.0.0 (2016-02-15)
===================
Expand Down
10 changes: 10 additions & 0 deletions mopidy/core/playback.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ def _on_about_to_finish(self):
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
Expand Down Expand Up @@ -394,6 +400,10 @@ def _change(self, pending_tl_track, state):
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()

Expand Down

0 comments on commit 5b6632e

Please sign in to comment.