From 50cd2a17734dee4c4739112261fc40974cce409a Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 2 Nov 2026 13:19:49 +0100 Subject: seek: jump within the current track from the CLI and over MPRIS `rsp seek 1:30`, `rsp seek +15`, `rsp seek -30` and `rsp seek` (print the position) drive a new AudioCommand that seeks the format reader, resets the decoder and drops the buffered samples, so the cpal stream keeps running and playback continues from the new spot. MPRIS gets a working Seek/SetPosition, reports CanSeek, and the state watcher now emits Seeked when the playhead jumps (not just on track changes), which is what clients need to move their progress bar after an external seek. `rsp status` also reports the position (and duration when known) and says Paused instead of Stopped when a track is loaded but not playing. --- src/cli.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/cli.rs') diff --git a/src/cli.rs b/src/cli.rs index 12bc3b0..79c31a8 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -68,6 +68,13 @@ pub enum Commands { Queue, /// Show player status Status, + /// Seek within the current track + Seek { + /// Position: `90`, `1:30`, `1:02:03`, or a relative offset `+15` / `-30`; + /// without one, the current position is printed + #[arg(value_name = "POSITION", allow_hyphen_values = true)] + position: Option, + }, /// Scan music paths to populate database Scan { #[arg(long)] @@ -198,6 +205,10 @@ impl Cli { Commands::Status => { crate::daemon::send_command("status".to_string())?; } + Commands::Seek { position } => match position { + Some(p) => crate::daemon::send_command(format!("seek {}", p))?, + None => crate::daemon::send_command("seek".to_string())?, + }, Commands::Scan { force, paths } => { let config = Config::load()?; let db = Database::open(&config)?; -- cgit v1.2.3