emit mpris seeked signal
This commit is contained in:
parent
d5d7ff882e
commit
162a151595
2 changed files with 20 additions and 2 deletions
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue