Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add definition of Seeked MPRIS signal #1315

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/dbus_mpris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,16 @@
.get(|_, _| Ok(Vec::<String>::new()));
});

let mut on_seeked: Option<

Check failure on line 229 in src/dbus_mpris.rs

View workflow job for this annotation

GitHub Actions / lint

very complex type used. Consider factoring parts into `type` definitions
Box<dyn Fn(&dbus::Path, &(i64,)) -> dbus::Message + Send + Sync + 'static>,
> = None;

// The following methods and properties are part of the MediaPlayer2.Player interface.
// https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html

let player_interface: IfaceToken<()> = cr.register("org.mpris.MediaPlayer2.Player", |b| {
on_seeked = Some(b.signal::<(i64,), _>("Seeked", ("Position",)).msg_fn());

let local_spirc = spirc.clone();
b.method("VolumeUp", (), (), move |_, _, (): ()| {
local_spirc.volume_up();
Expand Down Expand Up @@ -688,14 +694,12 @@
}

// if position in track has changed emit a Seeked signal
if let Some(position_ms) = seeked_position_ms {
let msg = dbus::message::Message::signal(
if let (Some(position_ms), Some(build_msg)) = (seeked_position_ms, &on_seeked) {
let msg = build_msg(
&dbus::Path::new("/org/mpris/MediaPlayer2").unwrap(),
&dbus::strings::Interface::new("org.mpris.MediaPlayer2.Player").unwrap(),
&dbus::strings::Member::new("Seeked").unwrap(),
)
// position should be in microseconds
.append1(position_ms as i64 * 1000);
&(position_ms as i64 * 1000,),
);

conn.send(msg).unwrap();
}
}
Expand Down
Loading