Skip to content
Extraits de code Groupes Projets
Vérifiée Valider e0d24b02 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

MPRIS: We will add custom types to help manipulating data when implementing the specification

parent ebb2d560
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -23,6 +23,8 @@ enum MediaPlayerPlaybackStatus { ...@@ -23,6 +23,8 @@ enum MediaPlayerPlaybackStatus {
Stopped, Stopped,
} }
struct µs(i32);
/// A valid path must be prefiexed by `/baka/lektor/`. After that we have the /// A valid path must be prefiexed by `/baka/lektor/`. After that we have the
/// variant name in lower case, then a `/`, then the ascii only value. For /// variant name in lower case, then a `/`, then the ascii only value. For
/// example we can have: /// example we can have:
...@@ -31,8 +33,16 @@ enum MediaPlayerObjectPath { ...@@ -31,8 +33,16 @@ enum MediaPlayerObjectPath {
Id(i64), Id(i64),
} }
impl From<String> for MediaPlayerLoopStatus {}
impl From<&str> for MediaPlayerLoopStatus {}
impl From<String> for MediaPlayerPlaybackStatus {}
impl From<&str> for MediaPlayerPlaybackStatus {}
impl<'a> From<zbus::zvariant::ObjectPath<'a>> for MediaPlayerObjectPath {} impl<'a> From<zbus::zvariant::ObjectPath<'a>> for MediaPlayerObjectPath {}
impl From<i32> for µs {}
#[dbus_proxy(interface = "org.mpris.MediaPlayer2", assume_defaults = true)] #[dbus_proxy(interface = "org.mpris.MediaPlayer2", assume_defaults = true)]
trait MediaPlayer2 { trait MediaPlayer2 {
/// Quit method /// Quit method
...@@ -74,7 +84,10 @@ trait MediaPlayer2 { ...@@ -74,7 +84,10 @@ trait MediaPlayer2 {
#[dbus_proxy(property)] #[dbus_proxy(property)]
fn supported_mime_types(&self) -> zbus::Result<Vec<String>>; fn supported_mime_types(&self) -> zbus::Result<Vec<String>>;
/// SupportedUriSchemes property /// SupportedUriSchemes property. It should be `id://` and `file://` for
/// lektord. Here we support `file://` for only files in the database to
/// enable the user to search the kara folder and drop the files to play
/// them imediatly.
#[dbus_proxy(property)] #[dbus_proxy(property)]
fn supported_uri_schemes(&self) -> zbus::Result<Vec<String>>; fn supported_uri_schemes(&self) -> zbus::Result<Vec<String>>;
} }
...@@ -103,7 +116,7 @@ trait Player { ...@@ -103,7 +116,7 @@ trait Player {
fn seek(&self, time_µs: i64) -> zbus::Result<()>; fn seek(&self, time_µs: i64) -> zbus::Result<()>;
/// SetPosition method /// SetPosition method
fn set_position(&self, track_id: &MediaPlayerObjectPath, time_µs: i64) -> zbus::Result<()>; fn set_position(&self, track_id: &MediaPlayerObjectPath, time_µs: µs) -> zbus::Result<()>;
/// Stop method /// Stop method
fn stop(&self) -> zbus::Result<()>; fn stop(&self) -> zbus::Result<()>;
...@@ -126,32 +139,42 @@ trait Player { ...@@ -126,32 +139,42 @@ trait Player {
/// LoopStatus property /// LoopStatus property
#[dbus_proxy(property)] #[dbus_proxy(property)]
fn loop_status(&self) -> zbus::Result<String>; fn loop_status(&self) -> zbus::Result<MediaPlayerObjectPath>;
fn set_loop_status(&self, value: &str) -> zbus::Result<()>; fn set_loop_status(&self, value: &MediaPlayerObjectPath) -> zbus::Result<()>;
/// MaximumRate property /// MaximumRate property. We will only set it to `1.0` here...
#[dbus_proxy(property)] #[dbus_proxy(property)]
fn maximum_rate(&self) -> zbus::Result<f64>; fn maximum_rate(&self) -> zbus::Result<f64> {
fn set_maximum_rate(&self, value: f64) -> zbus::Result<()>; Ok(1.0)
}
fn set_maximum_rate(&self, _: f64) -> zbus::Result<()> {
Ok(())
}
/// Metadata property /// Metadata property. If there is a current kara playing, there must be at
/// least a `mpris:trackid` value of type `o` which is the object path of
/// the current kara id.
#[dbus_proxy(property)] #[dbus_proxy(property)]
fn metadata( fn metadata(
&self, &self,
) -> zbus::Result<std::collections::HashMap<String, zbus::zvariant::OwnedValue>>; ) -> zbus::Result<std::collections::HashMap<String, zbus::zvariant::OwnedValue>>;
/// MinimumRate property /// MinimumRate property. We will only set it to `1.0` here...
#[dbus_proxy(property)] #[dbus_proxy(property)]
fn minimum_rate(&self) -> zbus::Result<f64>; fn minimum_rate(&self) -> zbus::Result<f64> {
fn set_minimum_rate(&self, value: f64) -> zbus::Result<()>; Ok(1.0)
}
fn set_minimum_rate(&self, _: f64) -> zbus::Result<()> {
Ok(())
}
/// PlaybackStatus property /// PlaybackStatus property
#[dbus_proxy(property)] #[dbus_proxy(property)]
fn playback_status(&self) -> zbus::Result<String>; fn playback_status(&self) -> zbus::Result<MediaPlayerPlaybackStatus>;
/// Position property /// Position property
#[dbus_proxy(property)] #[dbus_proxy(property)]
fn position(&self) -> zbus::Result<i32>; fn position(&self) -> zbus::Result<µs>;
/// Rate property /// Rate property
#[dbus_proxy(property)] #[dbus_proxy(property)]
...@@ -160,8 +183,8 @@ trait Player { ...@@ -160,8 +183,8 @@ trait Player {
/// Shuffle property /// Shuffle property
#[dbus_proxy(property)] #[dbus_proxy(property)]
fn shuffle(&self) -> zbus::Result<f64>; fn shuffle(&self) -> zbus::Result<bool>;
fn set_shuffle(&self, value: f64) -> zbus::Result<()>; fn set_shuffle(&self, value: bool) -> zbus::Result<()>;
/// Volume property /// Volume property
#[dbus_proxy(property)] #[dbus_proxy(property)]
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<property name="PlaybackStatus" type="s" access="read" /> <property name="PlaybackStatus" type="s" access="read" />
<property name="LoopStatus" type="s" access="readwrite" /> <property name="LoopStatus" type="s" access="readwrite" />
<property name="Volume" type="d" access="readwrite" /> <property name="Volume" type="d" access="readwrite" />
<property name="Shuffle" type="d" access="readwrite" /> <property name="Shuffle" type="b" access="readwrite" />
<property name="Position" type="i" access="read" /> <property name="Position" type="i" access="read" />
<property name="Rate" type="d" access="readwrite" /> <property name="Rate" type="d" access="readwrite" />
<property name="MinimumRate" type="d" access="readwrite" /> <property name="MinimumRate" type="d" access="readwrite" />
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter