From 85387a0a9be7a44ae0d1b6c80a267d71f632d130 Mon Sep 17 00:00:00 2001 From: Zander Brown Date: Mon, 5 Nov 2018 17:55:46 +0000 Subject: [PATCH 1/2] Fix for https://gitlab.gnome.org/World/podcasts/issues/105 Wow that was a quick one --- podcasts-gtk/src/widgets/player.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/podcasts-gtk/src/widgets/player.rs b/podcasts-gtk/src/widgets/player.rs index fa65a8d..f95d817 100644 --- a/podcasts-gtk/src/widgets/player.rs +++ b/podcasts-gtk/src/widgets/player.rs @@ -561,6 +561,7 @@ impl PlayerExt for PlayerWidget { let duration = self.player.get_duration(); let destination = match direction { SeekDirection::Backwards if position >= offset => Some(position - offset), + SeekDirection::Backwards if position < offset => Some(ClockTime::from_seconds(0)), SeekDirection::Forward if !duration.is_none() && position + offset <= duration => { Some(position + offset) } From fbda4c76f0164859146bc8837966a4da17c9be67 Mon Sep 17 00:00:00 2001 From: Zander Brown Date: Mon, 5 Nov 2018 21:39:07 +0000 Subject: [PATCH 2/2] player.rs: Improve the fast-forward handling Previously if you hit fast-forward but the offset remaining was let that the amount you wanted to seek, it would do nothing. Now it resets the stream and seekbar to the start. Eventually this will just move on to the next episode in the Queue once that's implemented. --- podcasts-gtk/src/widgets/player.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/podcasts-gtk/src/widgets/player.rs b/podcasts-gtk/src/widgets/player.rs index f95d817..8492255 100644 --- a/podcasts-gtk/src/widgets/player.rs +++ b/podcasts-gtk/src/widgets/player.rs @@ -553,21 +553,32 @@ impl PlayerExt for PlayerWidget { // Adapted from https://github.com/philn/glide/blob/b52a65d99daeab0b487f79a0e1ccfad0cd433e22/src/player_context.rs#L219-L245 fn seek(&self, offset: ClockTime, direction: SeekDirection) { + // How far into the podcast we are let position = self.player.get_position(); if position.is_none() || offset.is_none() { return; } + // How much podcast we have let duration = self.player.get_duration(); let destination = match direction { + // If we are more than `offset` into the podcast, jump back that far SeekDirection::Backwards if position >= offset => Some(position - offset), + // If we haven't played `offset` yet just restart the podcast SeekDirection::Backwards if position < offset => Some(ClockTime::from_seconds(0)), + // If we have more than `offset` remaining jump forward they amount SeekDirection::Forward if !duration.is_none() && position + offset <= duration => { Some(position + offset) } + // We don't have `offset` remaining just move to the end (ending playback) + SeekDirection::Forward if !duration.is_none() && position + offset > duration => { + Some(duration) + } + // Who knows what's going on ¯\_(ツ)_/¯ _ => None, }; + // If we calucated a new position, jump to it destination.map(|d| self.player.seek(d)); }