From fcaaa5e645f277f79a871cd960ec637121e11782 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Wed, 27 Jul 2011 00:08:17 +0200 Subject: [PATCH] Remove workaround from last to commits in favor of fix of root cause. Problem was that 'elapsed' should be returned in seconds, not milliseconds --- mopidy/frontends/mpd/protocol/status.py | 15 +++++---------- tests/frontends/mpd/status_test.py | 4 ++-- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/mopidy/frontends/mpd/protocol/status.py b/mopidy/frontends/mpd/protocol/status.py index 8fe83be5..0b5ff1df 100644 --- a/mopidy/frontends/mpd/protocol/status.py +++ b/mopidy/frontends/mpd/protocol/status.py @@ -137,7 +137,7 @@ def status(context): Reports the current status of the player and the volume level. - - ``volume``: 0-100 + - ``volume``: 0-100 (or -1 if no output is set). - ``repeat``: 0 or 1 - ``single``: 0 or 1 - ``consume``: 0 or 1 @@ -153,7 +153,8 @@ def status(context): - ``nextsongid``: playlist songid of the next song to be played - ``time``: total time elapsed (of current playing/paused song) - ``elapsed``: Total time elapsed within the current song, but with - higher resolution. + higher resolution (i.e. time in seconds with milliseconds in decimal + places). - ``bitrate``: instantaneous bitrate in kbps - ``xfade``: crossfade in seconds - ``audio``: sampleRate``:bits``:channels @@ -242,17 +243,11 @@ def _status_state(futures): return u'pause' def _status_time(futures): - return u'%s:%s' % (_status_time_elapsed(futures) // 1000, + return u'%d:%d' % (futures['playback.time_position'].get() // 1000, _status_time_total(futures) // 1000) def _status_time_elapsed(futures): - time_position = futures['playback.time_position'].get() - if time_position < 1000: - # XXX ncmpcpp and mpc interpretes the elapsed time as seconds instead - # of milliseconds if the elapsed time is less than approx. 1000. - return 0 - else: - return time_position + return u'%.3f' % (futures['playback.time_position'].get() / 1000.0) def _status_time_total(futures): current_cp_track = futures['playback.current_cp_track'].get() diff --git a/tests/frontends/mpd/status_test.py b/tests/frontends/mpd/status_test.py index a7eeeb5e..2f97a7d4 100644 --- a/tests/frontends/mpd/status_test.py +++ b/tests/frontends/mpd/status_test.py @@ -163,14 +163,14 @@ class StatusHandlerTest(unittest.TestCase): self.backend.playback.play_time_accumulated = 59123 result = dict(status.status(self.context)) self.assert_('elapsed' in result) - self.assertEqual(int(result['elapsed']), 59123) + 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 result = dict(status.status(self.context)) self.assert_('elapsed' in result) - self.assertEqual(int(result['elapsed']), 0) # Zero + self.assertEqual(result['elapsed'], '0.123') def test_status_method_when_playing_contains_bitrate(self): self.backend.current_playlist.append([Track(bitrate=320)])