diff --git a/src/mpris/player.rs b/src/mpris/player.rs index 5564049..e830936 100644 --- a/src/mpris/player.rs +++ b/src/mpris/player.rs @@ -6,7 +6,7 @@ use tracing::{event, Level}; use zbus::object_server::{InterfaceRef, SignalEmitter}; use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Value}; -const MICROSECONDS: f64 = 1e6; // in a second +pub const MICROSECONDS: f64 = 1e6; // in a second #[derive(Default)] pub struct MetadataMap { @@ -287,7 +287,7 @@ impl Player { } #[zbus(signal)] - async fn seeked(emitter: &SignalEmitter<'_>, position: i64) -> zbus::Result<()>; + pub async fn seeked(emitter: &SignalEmitter<'_>, position: i64) -> zbus::Result<()>; #[zbus(property)] fn playback_status(&self) -> String { diff --git a/src/ui/window.rs b/src/ui/window.rs index b12670a..cadce24 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -807,6 +807,24 @@ mod imp { self.obj().notify("time-pos"); self.buffering_start(); + + let time_pos = self.obj().time_pos(); + if let Some(iface_ref) = self.mpris_player() { + glib::spawn_future_local(async move { + match mpris::Player::seeked( + iface_ref.signal_emitter(), + (time_pos * mpris::player::MICROSECONDS) as i64, + ) + .await + { + Ok(()) => {} + Err(err) => event!( + Level::ERROR, + "could not notify seek through mpris interface: {err}" + ), + } + }); + } } fn on_playback_restart(&self) {