From 7c16f3e0b4172d5126217b4581b01cd67f44978c Mon Sep 17 00:00:00 2001 From: Josh Megnauth Date: Sun, 18 May 2025 00:05:43 -0400 Subject: [PATCH] Retain paused/playing state on scrub Closes: #110 Prior to this patch, seeking incorrectly resumed playing even if the player was paused when it should stay paused. --- src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index bc39929..d5fde84 100644 --- a/src/main.rs +++ b/src/main.rs @@ -274,6 +274,7 @@ pub struct App { position: f64, duration: f64, dragging: bool, + paused_on_scrub: bool, audio_codes: Vec, audio_tags: Vec, current_audio: i32, @@ -816,6 +817,7 @@ impl Application for App { position: 0.0, duration: 0.0, dragging: false, + paused_on_scrub: false, audio_codes: Vec::new(), audio_tags: Vec::new(), current_audio: -1, @@ -1183,6 +1185,7 @@ impl Application for App { if let Some(video) = &mut self.video_opt { self.dragging = true; self.position = secs; + self.paused_on_scrub = video.paused(); video.set_paused(true); let duration = Duration::try_from_secs_f64(self.position).unwrap_or_default(); video.seek(duration, true).expect("seek"); @@ -1205,7 +1208,7 @@ impl Application for App { self.dragging = false; let duration = Duration::try_from_secs_f64(self.position).unwrap_or_default(); video.seek(duration, true).expect("seek"); - video.set_paused(false); + video.set_paused(self.paused_on_scrub); self.update_controls(true); } }