From c5adcddb1ef88390875cd98995fb6dbb26545fa0 Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Fri, 2 Oct 2026 19:27:27 +0200 Subject: [PATCH] feat(player): subtitle position and playback speed --- crates/pstr-player/src/player.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/pstr-player/src/player.rs b/crates/pstr-player/src/player.rs index fc54809..4930e0c 100644 --- a/crates/pstr-player/src/player.rs +++ b/crates/pstr-player/src/player.rs @@ -449,6 +449,24 @@ impl Player { Ok(()) } + /// Where subtitles sit, as a percentage of the window's height from the + /// top: 100 is mpv's usual place along the bottom edge. + /// + /// `sub-pos` rather than a margin, because it moves styled (ASS) subtitles + /// too — and those are most of what an anime library carries. + pub fn set_subtitle_position(&self, percent: f64) -> Result<()> { + self.mpv + .set_property("sub-pos", percent.clamp(0.0, 150.0).round() as i64)?; + Ok(()) + } + + /// Playback speed, where 1.0 is normal. Pitch is corrected, which is mpv's + /// default and what keeps a voice a voice at 1.5×. + pub fn set_speed(&self, speed: f64) -> Result<()> { + self.mpv.set_property("speed", speed.clamp(0.25, 4.0))?; + Ok(()) + } + pub fn stop(&self) -> Result<()> { self.mpv.command("stop", &[])?; Ok(())