implement set_volume
This commit is contained in:
parent
48c587ec65
commit
608a47aa5d
2 changed files with 18 additions and 7 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -79,9 +79,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-compression"
|
name = "async-compression"
|
||||||
version = "0.4.12"
|
version = "0.4.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fec134f64e2bc57411226dfc4e52dec859ddfc7e711fc5e07b612584f000e4aa"
|
checksum = "0cb8f1d480b0ea3783ab015936d2a55c87e219676f0c0b7dec61494043f21857"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"flate2",
|
"flate2",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
|
|
|
@ -241,42 +241,50 @@ impl Player {
|
||||||
|
|
||||||
#[zbus::interface(name = "org.mpris.MediaPlayer2.Player")]
|
#[zbus::interface(name = "org.mpris.MediaPlayer2.Player")]
|
||||||
impl Player {
|
impl Player {
|
||||||
|
#[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)]
|
||||||
fn next(&self) -> zbus::fdo::Result<()> {
|
fn next(&self) -> zbus::fdo::Result<()> {
|
||||||
self.window().playlist_next();
|
self.window().playlist_next();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)]
|
||||||
fn previous(&self) -> zbus::fdo::Result<()> {
|
fn previous(&self) -> zbus::fdo::Result<()> {
|
||||||
self.window().playlist_prev();
|
self.window().playlist_prev();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)]
|
||||||
fn pause(&self) -> zbus::fdo::Result<()> {
|
fn pause(&self) -> zbus::fdo::Result<()> {
|
||||||
self.window().set_pause(true);
|
self.window().set_pause(true);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)]
|
||||||
fn play_pause(&self) -> zbus::fdo::Result<()> {
|
fn play_pause(&self) -> zbus::fdo::Result<()> {
|
||||||
self.window().set_pause(!self.window().pause());
|
self.window().set_pause(!self.window().pause());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)]
|
||||||
fn stop(&self) -> zbus::fdo::Result<()> {
|
fn stop(&self) -> zbus::fdo::Result<()> {
|
||||||
self.window().set_pause(true);
|
self.window().set_pause(true);
|
||||||
self.window().set_time_pos(0.0);
|
self.window().set_time_pos(0.0);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)]
|
||||||
fn play(&self) -> zbus::fdo::Result<()> {
|
fn play(&self) -> zbus::fdo::Result<()> {
|
||||||
self.window().set_pause(false);
|
self.window().set_pause(false);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)]
|
||||||
fn seek(&self, offset: i64) -> zbus::fdo::Result<()> {
|
fn seek(&self, offset: i64) -> zbus::fdo::Result<()> {
|
||||||
self.window().seek(offset as f64 / MICROSECONDS);
|
self.window().seek(offset as f64 / MICROSECONDS);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)]
|
||||||
fn set_position(&self, track_id: ObjectPath<'_>, position: i64) -> zbus::fdo::Result<()> {
|
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()) {
|
if Some(track_id) == self.metadata.track_id.as_ref().map(|x| x.as_ref()) {
|
||||||
self.window().set_time_pos(position as f64 / MICROSECONDS);
|
self.window().set_time_pos(position as f64 / MICROSECONDS);
|
||||||
|
@ -284,6 +292,7 @@ impl Player {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)]
|
||||||
fn open_uri(&self, _s: String) -> zbus::fdo::Result<()> {
|
fn open_uri(&self, _s: String) -> zbus::fdo::Result<()> {
|
||||||
Err(zbus::fdo::Error::NotSupported("OpenUri".into()))
|
Err(zbus::fdo::Error::NotSupported("OpenUri".into()))
|
||||||
}
|
}
|
||||||
|
@ -318,13 +327,13 @@ impl Player {
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
fn set_rate(&self, _rate: f64) -> zbus::Result<()> {
|
fn set_rate(&self, _rate: f64) -> zbus::Result<()> {
|
||||||
// A value of 0.0 should not be set by the client. If it is, the media player should act as though Pause was called.
|
// A value of 0.0 should not be set by the client. If it is, the media player should act as though Pause was called.
|
||||||
todo!()
|
Err(zbus::fdo::Error::NotSupported("setting Rate".into()).into()) // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
#[zbus(property)]
|
|
||||||
// FIXME: https://github.com/dbus2/zbus/issues/992
|
// FIXME: https://github.com/dbus2/zbus/issues/992
|
||||||
|
#[zbus(property)]
|
||||||
fn shuffle(&self) -> zbus::fdo::Result<bool> {
|
fn shuffle(&self) -> zbus::fdo::Result<bool> {
|
||||||
Ok(false)
|
Err(zbus::fdo::Error::NotSupported("Shuffle".into()).into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
|
@ -344,8 +353,10 @@ impl Player {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
fn set_volume(&self, _volume: f64) -> zbus::Result<()> {
|
#[tracing::instrument(skip(self), parent = None, target = "audrey::mpris", level = Level::DEBUG, ret)]
|
||||||
todo!()
|
fn set_volume(&self, volume: f64) -> zbus::Result<()> {
|
||||||
|
let corrected_volume = (volume.clamp(0.0, 1.0) * 100.0) as i64;
|
||||||
|
Ok(self.window().set_volume(corrected_volume))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[zbus(property(emits_changed_signal = "false"))]
|
#[zbus(property(emits_changed_signal = "false"))]
|
||||||
|
|
Loading…
Reference in a new issue