bpd: provide precision time in status

This commit is contained in:
Carl Suster 2019-04-02 11:15:00 +11:00
parent 4be2e1b5e6
commit 28db7d3d33
2 changed files with 8 additions and 6 deletions

View file

@ -1045,10 +1045,12 @@ class Server(BaseServer):
(pos, total) = self.player.time()
yield (
u'time: ' + six.text_type(pos) + u':' + six.text_type(total),
# TODO provide elapsed and duration with higher precision
u'elapsed: ' + six.text_type(float(pos)),
u'duration: ' + six.text_type(float(total)),
u'time: {}:{}'.format(
six.text_type(int(pos)),
six.text_type(int(total)),
),
u'elapsed: ' + u'{:.3f}'.format(pos),
u'duration: ' + u'{:.3f}'.format(total),
)
# Also missing 'updating_db'.

View file

@ -177,12 +177,12 @@ class GstPlayer(object):
posq = self.player.query_position(fmt)
if not posq[0]:
raise QueryError("query_position failed")
pos = posq[1] // (10 ** 9)
pos = posq[1] / (10 ** 9)
lengthq = self.player.query_duration(fmt)
if not lengthq[0]:
raise QueryError("query_duration failed")
length = lengthq[1] // (10 ** 9)
length = lengthq[1] / (10 ** 9)
self.cached_time = (pos, length)
return (pos, length)