diff --git a/hammond-gtk/src/widgets/player.rs b/hammond-gtk/src/widgets/player.rs index 974fdc3..8250ed6 100644 --- a/hammond-gtk/src/widgets/player.rs +++ b/hammond-gtk/src/widgets/player.rs @@ -31,6 +31,7 @@ pub enum SeekDirection { pub trait PlayerExt { fn play(&self); fn pause(&self); + // fn stop(&self); fn seek(&self, offset: ClockTime, direction: SeekDirection); fn fast_forward(&self); fn rewind(&self); @@ -189,6 +190,8 @@ impl PlayerWidget { // Connect the fast-forward button to the gst Player. s.controls.forward.connect_clicked(clone!(s => move |_| s.fast_forward())); + // s.player.connect_end_of_stream(move |p| p.stop()); + s.player.connect_error(clone!(sender => move |_, error| { // FIXME: should never occur and should not be user facing. sender.send(Action::ErrorNotification(format!("Player Error: {}", error))) @@ -319,7 +322,7 @@ impl PlayerExt for PlayerWidget { } fn pause(&self) { - // assert the state is paused + // assert the state is paused or ready // TODO: assert!() self.controls.pause.hide(); @@ -328,6 +331,12 @@ impl PlayerExt for PlayerWidget { self.player.pause(); } + // This needs to be Send to be used with the `connect_end_of_stream` method. + // fn stop(&self) { + // self.player().stop(); + // self.pause(); + // } + // Adapted from https://github.com/philn/glide/blob/b52a65d99daeab0b487f79a0e1ccfad0cd433e22/src/player_context.rs#L219-L245 fn seek(&self, offset: ClockTime, direction: SeekDirection) { let position = self.player.get_position();