From 81fca7d68674c4784c35cd770423549cd429934b Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Thu, 20 Sep 2012 19:33:34 +0200 Subject: [PATCH] Switch to time position from provider --- mopidy/core/playback.py | 3 +++ tests/frontends/mpd/status_test.py | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/mopidy/core/playback.py b/mopidy/core/playback.py index 9f6030c1..1bebd270 100644 --- a/mopidy/core/playback.py +++ b/mopidy/core/playback.py @@ -307,6 +307,9 @@ class PlaybackController(object): @property def time_position(self): """Time position in milliseconds.""" + return self.provider.get_time_position() + + def _wall_clock_based_time_position(): if self.state == PlaybackState.PLAYING: time_since_started = (self._current_wall_time - self.play_time_started) diff --git a/tests/frontends/mpd/status_test.py b/tests/frontends/mpd/status_test.py index 59418a3b..2397b96f 100644 --- a/tests/frontends/mpd/status_test.py +++ b/tests/frontends/mpd/status_test.py @@ -159,18 +159,21 @@ class StatusHandlerTest(unittest.TestCase): self.assertLessEqual(position, total) def test_status_method_when_playing_contains_elapsed(self): - self.backend.playback.state = PAUSED - self.backend.playback.play_time_accumulated = 59123 + self.backend.current_playlist.append([Track(length=60000)]) + self.backend.playback.play() + self.backend.playback.pause() + self.backend.playback.seek(59123) result = dict(status.status(self.context)) self.assertIn('elapsed', result) self.assertEqual(result['elapsed'], '59.123') def test_status_method_when_starting_playing_contains_elapsed_zero(self): - self.backend.playback.state = PAUSED - self.backend.playback.play_time_accumulated = 123 # Less than 1000ms + self.backend.current_playlist.append([Track(length=10000)]) + self.backend.playback.play() + self.backend.playback.pause() result = dict(status.status(self.context)) self.assertIn('elapsed', result) - self.assertEqual(result['elapsed'], '0.123') + self.assertEqual(result['elapsed'], '0.000') def test_status_method_when_playing_contains_bitrate(self): self.backend.current_playlist.append([Track(bitrate=320)])