some mpris work

This commit is contained in:
Erica Z 2024-11-16 14:42:28 +01:00
parent 1757e64961
commit 932471218a

View file

@ -242,35 +242,46 @@ impl Player {
#[zbus::interface(name = "org.mpris.MediaPlayer2.Player")]
impl Player {
fn next(&self) -> zbus::fdo::Result<()> {
Err(zbus::fdo::Error::NotSupported("not implemented".into()))
self.window().playlist_next();
Ok(())
}
fn previous(&self) -> zbus::fdo::Result<()> {
Err(zbus::fdo::Error::NotSupported("not implemented".into()))
self.window().playlist_prev();
Ok(())
}
fn pause(&self) -> zbus::fdo::Result<()> {
Err(zbus::fdo::Error::NotSupported("not implemented".into()))
self.window().set_pause(true);
Ok(())
}
fn play_pause(&self) -> zbus::fdo::Result<()> {
Err(zbus::fdo::Error::NotSupported("not implemented".into()))
self.window().set_pause(!self.window().pause());
Ok(())
}
fn stop(&self) -> zbus::fdo::Result<()> {
Err(zbus::fdo::Error::NotSupported("not implemented".into()))
self.window().set_pause(true);
self.window().set_time_pos(0.0);
Ok(())
}
fn play(&self) -> zbus::fdo::Result<()> {
Err(zbus::fdo::Error::NotSupported("not implemented".into()))
self.window().set_pause(false);
Ok(())
}
fn seek(&self, _offset: i64) -> zbus::fdo::Result<()> {
Err(zbus::fdo::Error::NotSupported("not implemented".into()))
fn seek(&self, offset: i64) -> zbus::fdo::Result<()> {
self.window().seek(offset as f64 / MICROSECONDS);
Ok(())
}
fn set_position(&self, _track_id: ObjectPath<'_>, _position: i64) -> zbus::fdo::Result<()> {
Err(zbus::fdo::Error::NotSupported("not implemented".into()))
fn set_position(&self, track_id: ObjectPath<'_>, position: i64) -> zbus::fdo::Result<()> {
if Some(track_id) == self.metadata.track_id.as_ref().map(|x| x.as_ref()) {
self.window().set_time_pos(position as f64 / MICROSECONDS);
}
Ok(())
}
fn open_uri(&self, _s: String) -> zbus::fdo::Result<()> {