Trait mpris_server::PlaylistsInterface
source · pub trait PlaylistsInterface:
PlayerInterface
+ Send
+ Sync {
// Required methods
fn activate_playlist(
&self,
playlist_id: PlaylistId,
) -> impl Future<Output = Result<()>> + Send + Sync;
fn get_playlists(
&self,
index: u32,
max_count: u32,
order: PlaylistOrdering,
reverse_order: bool,
) -> impl Future<Output = Result<Vec<Playlist>>> + Send + Sync;
fn playlist_count(&self) -> impl Future<Output = Result<u32>> + Send + Sync;
fn orderings(
&self,
) -> impl Future<Output = Result<Vec<PlaylistOrdering>>> + Send + Sync;
fn active_playlist(
&self,
) -> impl Future<Output = Result<Option<Playlist>>> + Send + Sync;
}
Expand description
Used to implement org.mpris.MediaPlayer2.Playlists interface, which provides access to the media player’s playlists.
Since D-Bus does not provide an easy way to check for what interfaces are exported on an object, clients should attempt to get one of the properties on this interface to see if it is implemented.
Required Methods§
sourcefn activate_playlist(
&self,
playlist_id: PlaylistId,
) -> impl Future<Output = Result<()>> + Send + Sync
fn activate_playlist( &self, playlist_id: PlaylistId, ) -> impl Future<Output = Result<()>> + Send + Sync
Starts playing the given playlist.
§Parameters
playlist_id
- The id of the playlist to activate.
Note that this must be implemented. If the media player does not allow clients to change the playlist, it should not implement this interface at all.
It is up to the media player whether this completely replaces the current tracklist, or whether it is merely inserted into the tracklist and the first track starts. For example, if the media player is operating in a “jukebox” mode, it may just append the playlist to the list of upcoming tracks, and skip to the first track in the playlist.
sourcefn get_playlists(
&self,
index: u32,
max_count: u32,
order: PlaylistOrdering,
reverse_order: bool,
) -> impl Future<Output = Result<Vec<Playlist>>> + Send + Sync
fn get_playlists( &self, index: u32, max_count: u32, order: PlaylistOrdering, reverse_order: bool, ) -> impl Future<Output = Result<Vec<Playlist>>> + Send + Sync
Gets a set of playlists.
§Parameters
index
- The index of the first playlist to be fetched (according to the ordering).max_count
- The maximum number of playlists to fetch.order
- The ordering that should be used.reverse_order
- Whether the order should be reversed.
§Returns
playlists
- A list of (at mostmax_count
) playlists.
sourcefn playlist_count(&self) -> impl Future<Output = Result<u32>> + Send + Sync
fn playlist_count(&self) -> impl Future<Output = Result<u32>> + Send + Sync
The number of playlists available.
When this property changes, the
org.freedesktop.DBus.Properties.PropertiesChanged
signal via
playlists_properties_changed
must be emitted with the new value.
sourcefn orderings(
&self,
) -> impl Future<Output = Result<Vec<PlaylistOrdering>>> + Send + Sync
fn orderings( &self, ) -> impl Future<Output = Result<Vec<PlaylistOrdering>>> + Send + Sync
The available orderings. At least one must be offered.
When this property changes, the
org.freedesktop.DBus.Properties.PropertiesChanged
signal via
playlists_properties_changed
must be emitted with the new value.
Rationale
Media players may not have access to all the data required for some orderings. For example, creation times are not available on UNIX filesystems (don’t let the ctime fool you!). On the other hand, clients should have some way to get the “most recent” playlists.
sourcefn active_playlist(
&self,
) -> impl Future<Output = Result<Option<Playlist>>> + Send + Sync
fn active_playlist( &self, ) -> impl Future<Output = Result<Option<Playlist>>> + Send + Sync
The currently-active playlist.
When this property changes, the
org.freedesktop.DBus.Properties.PropertiesChanged
signal via
playlists_properties_changed
must be emitted with the new value.
If there is no currently-active playlist, this should return None
.
Note that this may not have a value even after ActivatePlaylist
is
called with a valid playlist id as ActivatePlaylist
implementations
have the option of simply inserting the contents of the playlist
into the current tracklist.