Implement music player SetPosition message

This commit is contained in:
mars 2022-11-21 21:06:03 -07:00
parent 2b058c7202
commit 238f4f878d
2 changed files with 7 additions and 0 deletions

View File

@ -111,6 +111,12 @@ async fn on_message(
OutMsg::Stop => player.stop().await?,
OutMsg::Previous => player.previous().await?,
OutMsg::Next => player.next().await?,
OutMsg::SetPosition { position } => {
let current = player.position().await?;
let next = (position * 1_000_000.0) as i64; // Seconds to microseconds
let offset = next - current;
player.seek(offset).await?;
}
_ => {}
}

View File

@ -17,6 +17,7 @@ trait Player {
fn play_pause(&self) -> Result<()>;
fn stop(&self) -> Result<()>;
fn play(&self) -> Result<()>;
fn seek(&self, offset: i64) -> Result<()>;
#[dbus_proxy(property)]
fn playback_status(&self) -> Result<String>;