Remove workaround from last to commits in favor of fix of root cause. Problem was that 'elapsed' should be returned in seconds, not milliseconds
This commit is contained in:
parent
6e2bfcf3d5
commit
fcaaa5e645
@ -137,7 +137,7 @@ def status(context):
|
|||||||
|
|
||||||
Reports the current status of the player and the volume level.
|
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
|
- ``repeat``: 0 or 1
|
||||||
- ``single``: 0 or 1
|
- ``single``: 0 or 1
|
||||||
- ``consume``: 0 or 1
|
- ``consume``: 0 or 1
|
||||||
@ -153,7 +153,8 @@ def status(context):
|
|||||||
- ``nextsongid``: playlist songid of the next song to be played
|
- ``nextsongid``: playlist songid of the next song to be played
|
||||||
- ``time``: total time elapsed (of current playing/paused song)
|
- ``time``: total time elapsed (of current playing/paused song)
|
||||||
- ``elapsed``: Total time elapsed within the current song, but with
|
- ``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
|
- ``bitrate``: instantaneous bitrate in kbps
|
||||||
- ``xfade``: crossfade in seconds
|
- ``xfade``: crossfade in seconds
|
||||||
- ``audio``: sampleRate``:bits``:channels
|
- ``audio``: sampleRate``:bits``:channels
|
||||||
@ -242,17 +243,11 @@ def _status_state(futures):
|
|||||||
return u'pause'
|
return u'pause'
|
||||||
|
|
||||||
def _status_time(futures):
|
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)
|
_status_time_total(futures) // 1000)
|
||||||
|
|
||||||
def _status_time_elapsed(futures):
|
def _status_time_elapsed(futures):
|
||||||
time_position = futures['playback.time_position'].get()
|
return u'%.3f' % (futures['playback.time_position'].get() / 1000.0)
|
||||||
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
|
|
||||||
|
|
||||||
def _status_time_total(futures):
|
def _status_time_total(futures):
|
||||||
current_cp_track = futures['playback.current_cp_track'].get()
|
current_cp_track = futures['playback.current_cp_track'].get()
|
||||||
|
|||||||
@ -163,14 +163,14 @@ class StatusHandlerTest(unittest.TestCase):
|
|||||||
self.backend.playback.play_time_accumulated = 59123
|
self.backend.playback.play_time_accumulated = 59123
|
||||||
result = dict(status.status(self.context))
|
result = dict(status.status(self.context))
|
||||||
self.assert_('elapsed' in result)
|
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):
|
def test_status_method_when_starting_playing_contains_elapsed_zero(self):
|
||||||
self.backend.playback.state = PAUSED
|
self.backend.playback.state = PAUSED
|
||||||
self.backend.playback.play_time_accumulated = 123 # Less than 1000ms
|
self.backend.playback.play_time_accumulated = 123 # Less than 1000ms
|
||||||
result = dict(status.status(self.context))
|
result = dict(status.status(self.context))
|
||||||
self.assert_('elapsed' in result)
|
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):
|
def test_status_method_when_playing_contains_bitrate(self):
|
||||||
self.backend.current_playlist.append([Track(bitrate=320)])
|
self.backend.current_playlist.append([Track(bitrate=320)])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user