Skip to content

Commit

Permalink
improved query duration/position
Browse files Browse the repository at this point in the history
  • Loading branch information
Nokse22 committed Jun 1, 2024
1 parent 34a32fd commit 8618a20
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,26 +339,19 @@ def update_slider(self, *args):
if not self.player_object.is_playing:
return False # cancel timeout
else:
success, self.duration = self.player_object.query_duration(Gst.Format.TIME)
if not success:
end_value = 100
pass
else:
end_value = self.duration / Gst.SECOND
self.progress_bar.set_range(0, end_value)

self.duration_label.set_label(utils.pretty_duration(end_value))

success, position = self.player_object.query_position(Gst.Format.TIME)
if not success:
pass
else:
position = position / Gst.SECOND
self.progress_bar.get_adjustment().set_value(position)
self.small_progress_bar.set_fraction(position/end_value)
self.previous_time = position

self.time_played_label.set_label(utils.pretty_duration(position))
self.duration = self.player_object.query_duration()
end_value = self.duration / Gst.SECOND
self.progress_bar.set_range(0, end_value)

self.duration_label.set_label(utils.pretty_duration(end_value))

position = self.player_object.query_position()
position = position / Gst.SECOND
self.progress_bar.get_adjustment().set_value(position)
self.small_progress_bar.set_fraction(position/end_value)
self.previous_time = position

self.time_played_label.set_label(utils.pretty_duration(position))
return True

@Gtk.Template.Callback("on_lyrics_button_clicked")
Expand Down

0 comments on commit 8618a20

Please sign in to comment.