Implement music player SetPosition message
This commit is contained in:
parent
2b058c7202
commit
238f4f878d
|
@ -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?;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
|
|
@ -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>;
|
||||
|
|
Loading…
Reference in New Issue