aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli.rs
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-02 13:19:49 +0100
committersalmonik <salmonik@tuta.io>2026-11-02 13:19:49 +0100
commit50cd2a17734dee4c4739112261fc40974cce409a (patch)
tree027366c170eb8dc035c5bd24be2669c41df64f28 /src/cli.rs
parentstate: persist the queue and pick up where playback stopped (diff)
downloadrsplayer-50cd2a17734dee4c4739112261fc40974cce409a.tar.gz
rsplayer-50cd2a17734dee4c4739112261fc40974cce409a.zip
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.
Diffstat (limited to '')
-rw-r--r--src/cli.rs11
1 files changed, 11 insertions, 0 deletions
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 {
68 Queue, 68 Queue,
69 /// Show player status 69 /// Show player status
70 Status, 70 Status,
71 /// Seek within the current track
72 Seek {
73 /// Position: `90`, `1:30`, `1:02:03`, or a relative offset `+15` / `-30`;
74 /// without one, the current position is printed
75 #[arg(value_name = "POSITION", allow_hyphen_values = true)]
76 position: Option<String>,
77 },
71 /// Scan music paths to populate database 78 /// Scan music paths to populate database
72 Scan { 79 Scan {
73 #[arg(long)] 80 #[arg(long)]
@@ -198,6 +205,10 @@ impl Cli {
198 Commands::Status => { 205 Commands::Status => {
199 crate::daemon::send_command("status".to_string())?; 206 crate::daemon::send_command("status".to_string())?;
200 } 207 }
208 Commands::Seek { position } => match position {
209 Some(p) => crate::daemon::send_command(format!("seek {}", p))?,
210 None => crate::daemon::send_command("seek".to_string())?,
211 },
201 Commands::Scan { force, paths } => { 212 Commands::Scan { force, paths } => {
202 let config = Config::load()?; 213 let config = Config::load()?;
203 let db = Database::open(&config)?; 214 let db = Database::open(&config)?;