don't reject some elapsed values

This commit is contained in:
Martin Wagner 2021-08-01 13:56:49 +02:00
parent 0e6a90b98a
commit 83f941f354

View File

@ -517,10 +517,6 @@ class ClientHelper():
base_song[tag]=song[tag][0] base_song[tag]=song[tag][0]
return base_song return base_song
def calc_display_duration(songs):
duration=sum([float(song.get("duration", 0.0)) for song in songs])
return ClientHelper.seconds_to_display_time(int(duration))
def binary_to_pixbuf(binary, size): def binary_to_pixbuf(binary, size):
loader=GdkPixbuf.PixbufLoader() loader=GdkPixbuf.PixbufLoader()
try: try:
@ -855,7 +851,7 @@ class Client(MPDClient):
if "duration" in status: if "duration" in status:
self.emitter.emit("elapsed_changed", float(val), float(status["duration"])) self.emitter.emit("elapsed_changed", float(val), float(status["duration"]))
else: else:
self.emitter.emit("elapsed_changed", 0.0, 0.0) self.emitter.emit("elapsed_changed", float(val), 0.0)
elif key == "bitrate": elif key == "bitrate":
if val == "0": if val == "0":
self.emitter.emit("bitrate", None) self.emitter.emit("bitrate", None)
@ -3301,14 +3297,18 @@ class SeekBar(Gtk.Box):
def _refresh(self, emitter, elapsed, duration): def _refresh(self, emitter, elapsed, duration):
self.set_sensitive(True) self.set_sensitive(True)
if elapsed > duration: # fix display error if duration > 0:
elapsed=duration if elapsed > duration: # fix display error
self._adjustment.set_upper(duration) elapsed=duration
if self._update: self._adjustment.set_upper(duration)
self._scale.set_value(elapsed) if self._update:
self._scale.set_value(elapsed)
self._elapsed.set_text(ClientHelper.seconds_to_display_time(int(elapsed)))
self._rest.set_text("-"+ClientHelper.seconds_to_display_time(int(duration-elapsed)))
self._scale.set_fill_level(elapsed)
else:
self._disable()
self._elapsed.set_text(ClientHelper.seconds_to_display_time(int(elapsed))) self._elapsed.set_text(ClientHelper.seconds_to_display_time(int(elapsed)))
self._rest.set_text("-"+ClientHelper.seconds_to_display_time(int(duration-elapsed)))
self._scale.set_fill_level(elapsed)
def _disable(self, *args): def _disable(self, *args):
self.set_sensitive(False) self.set_sensitive(False)