@@ 100,7 100,6 @@ class PlayerScreen(Adw.NavigationPage):
def display_error(self):
status = Adw.StatusPage()
status.set_title(_("*crickets chirping*"))
- subs = get_subscribed_channels()
status.set_description(_("Video could not be loaded"))
status.set_icon_name("weather-few-clouds-night-symbolic")
self.scrollview.set_child(status)
@@ 172,8 172,10 @@ class VideoPlayer(Gtk.Overlay):
self.progress_display = Gtk.Scale()
# highlight section left of playhead
self.progress_display.set_has_origin(True)
- # TODO: fix progress bar width
+ # manually set width
self.progress_display.set_hexpand(True)
+ self.progress_display.set_size_request(160, 20)
+ self.progress_display.connect("change-value", lambda r, s, v: self.goto(v))
self.controls.append(self.progress_display)
self.duration_display = Gtk.Label()
@@ 233,7 235,7 @@ class VideoPlayer(Gtk.Overlay):
# also calls swipe for clicks (and on swipe end)
# so we use this to handle the onclick event to toggle the controls (mobile)
self.swipe_ctr.connect("swipe", self._end_swipe)
- self.add_controller(self.swipe_ctr)
+ self.picture.add_controller(self.swipe_ctr)
# initialize volume & brightness
self.change_brightness(self.brightness)
@@ 320,15 322,19 @@ class VideoPlayer(Gtk.Overlay):
def _mouse_leave(self, w):
self._schedule_hide_controls()
+ _click_opened_controls = False
def _onclick(self):
# single click toggles focus
# because floats are a thing we can't use ==
# however given that we switch between 0 and 1
# we can use 0.9 or 0.1 as breakpoints
if self.controls.get_opacity() >= 0.9:
- self._hide_controls(force=True)
+ if self._click_opened_controls:
+ self._click_opened_controls = False
+ self._hide_controls(force=True)
else:
self._show_controls()
+ self._click_opened_controls = True
def _update_quality_list(self):
# TODO consider making this scrollable
@@ 359,6 365,8 @@ class VideoPlayer(Gtk.Overlay):
# run once every second
GLib.timeout_add(1000, self._loop)
def _loop(self):
+ if self.stopped:
+ return False
dur = self.source.query_duration(Gst.Format.TIME)
pos = self.source.query_position(Gst.Format.TIME)
# compare the nanoseconds values before converting them to seconds
@@ 399,9 407,7 @@ class VideoPlayer(Gtk.Overlay):
elif not dur is None:
self.set_duration(dur)
- # returns false if the video was stopped
- # which will stop the loop
- return not self.stopped
+ return True
def set_position_and_duration(self, pos, dur):
self.position = pos
@@ 430,8 436,7 @@ class VideoPlayer(Gtk.Overlay):
dur_text = format_seconds(self.duration)
self.position_display.set_label(pos_text)
self.duration_display.set_label(dur_text)
- # TODO fix progressbar
- # BUG: the continuous update cancels change events
+
if not self.duration is None and not self.position is None:
self.progress_display.set_range(0, self.duration)
self.progress_display.set_value(self.position)
@@ 442,6 447,7 @@ class VideoPlayer(Gtk.Overlay):
def play(self):
self.paused = False
+ self.source.set_property("instant-uri", self.stream.url)
self._start_loop()
self.source.set_state(Gst.State.PLAYING)
# show pause button
@@ 457,9 463,12 @@ class VideoPlayer(Gtk.Overlay):
self.paused = True
self.stopped = True
self.source.set_state(Gst.State.NULL)
+ self.source.set_property("instant-uri", None)
self.playpause_display.update("", "media-playback-start-symbolic", tooltip=_("Play"))
def _toggle_playpause(self, _):
+ if self.stopped:
+ self.target_position = 0
if self.paused:
self.play()
else: