From 35a475e45b32c626548bc5a82de73e8871b0ce19 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Sat, 23 Jun 2018 16:08:24 +0300 Subject: [PATCH] PlayerWidget: Tweak rewind on pause behavior. Only rewind on pause if the stream position is passed a certain point. Else it can feel a bit weird if you just started the stream and it immediatly rewinds. --- hammond-gtk/src/widgets/player.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hammond-gtk/src/widgets/player.rs b/hammond-gtk/src/widgets/player.rs index 0dc73a5..4ec2362 100644 --- a/hammond-gtk/src/widgets/player.rs +++ b/hammond-gtk/src/widgets/player.rs @@ -375,7 +375,13 @@ impl PlayerExt for PlayerWidget { self.controls.play.show(); self.player.pause(); - self.seek(ClockTime::from_seconds(5), SeekDirection::Backwards); + + // Only rewind on pause if the stream position is passed a certain point. + if let Some(sec) = self.player.get_position().seconds() { + if sec >= 90 { + self.seek(ClockTime::from_seconds(5), SeekDirection::Backwards); + } + } } #[cfg_attr(rustfmt, rustfmt_skip)] @@ -385,6 +391,7 @@ impl PlayerExt for PlayerWidget { self.player.stop(); + // Reset the slider bar to the start self.timer.on_position_updated(Position(ClockTime::from_seconds(0))); }