pub struct Player { /* private fields */ }Expand description
Simplified access to the controls of an MPRIS media player.
Implementations§
Source§impl Player
impl Player
Sourcepub async fn new(connection: &Connection, name: OwnedBusName) -> Result<Self>
pub async fn new(connection: &Connection, name: OwnedBusName) -> Result<Self>
Creates a new instance of the org.mpris.MediaPlayer2.Player interface.
Sourcepub async fn media_player(&self) -> Result<MediaPlayer>
pub async fn media_player(&self) -> Result<MediaPlayer>
Returns this player’s org.mpris.MediaPlayer2 instance
Sourcepub async fn seek<D>(&self, duration: D) -> Result<bool>where
D: Into<MprisDuration>,
pub async fn seek<D>(&self, duration: D) -> Result<bool>where
D: Into<MprisDuration>,
Seeks the specified duration.
Sourcepub async fn set_position<D>(&self, track: TrackId, position: D) -> Result<()>where
D: Into<MprisDuration>,
pub async fn set_position<D>(&self, track: TrackId, position: D) -> Result<()>where
D: Into<MprisDuration>,
Sets the current track position.
If track does not match the id of the currently-playing track, the call is ignored as “stale”.
Sourcepub async fn position(&self) -> Result<Option<MprisDuration>>
pub async fn position(&self) -> Result<Option<MprisDuration>>
How far into the current track the player is.
Not all players support this, and it will return None if this is the case.
Sourcepub async fn playback_status(&self) -> Result<PlaybackStatus>
pub async fn playback_status(&self) -> Result<PlaybackStatus>
Gets the current playback status of the player.
Sourcepub async fn rate(&self) -> Result<Option<f64>>
pub async fn rate(&self) -> Result<Option<f64>>
Returns the current rate of playback.
Not all players support this, and it will return None if this is the case.
Sourcepub async fn minimum_rate(&self) -> Result<Option<f64>>
pub async fn minimum_rate(&self) -> Result<Option<f64>>
Returns the minimum supported rate for the player.
Not all players support this, and it will return None if this is the case.
Sourcepub async fn maximum_rate(&self) -> Result<Option<f64>>
pub async fn maximum_rate(&self) -> Result<Option<f64>>
Returns the minimum supported rate for the player.
Not all players support this, and it will return None if this is the case.
Sourcepub async fn available_rates(&self) -> Result<Option<RangeInclusive<f64>>>
pub async fn available_rates(&self) -> Result<Option<RangeInclusive<f64>>>
Returns the range of playback rates available for the player.
Not all players support this, and it will return None if this is the case.
Sourcepub async fn shuffle(&self) -> Result<Option<bool>>
pub async fn shuffle(&self) -> Result<Option<bool>>
Whether the current playlist is shuffled or not.
A value of false indicates that playback is progressing linearly through a playlist, while true means playback is progressing through a playlist in some other order.
Sourcepub async fn set_shuffle(&self, value: bool) -> Result<()>
pub async fn set_shuffle(&self, value: bool) -> Result<()>
Set whether the current playlist is shuffled or not.
A value of false indicates that playback is progressing linearly through a playlist, while true means playback is progressing through a playlist in some other order.
Sourcepub async fn loop_status(&self) -> Result<Option<LoopStatus>>
pub async fn loop_status(&self) -> Result<Option<LoopStatus>>
The current loop / repeat status.
Sourcepub async fn set_loop_status(&self, value: LoopStatus) -> Result<()>
pub async fn set_loop_status(&self, value: LoopStatus) -> Result<()>
Set the current loop / repeat status.
Methods from Deref<Target = PlayerProxy<'static>>§
Sourcepub async fn play_pause(&self) -> Result<()>
pub async fn play_pause(&self) -> Result<()>
PlayPause method
Sourcepub async fn seek(&self, offset: MprisDuration) -> Result<()>
pub async fn seek(&self, offset: MprisDuration) -> Result<()>
Seek method
Sourcepub async fn set_position(
&self,
track_id: TrackId,
position: MprisDuration,
) -> Result<()>
pub async fn set_position( &self, track_id: TrackId, position: MprisDuration, ) -> Result<()>
SetPosition method
Sourcepub async fn receive_seeked(&self) -> Result<SeekedStream>
pub async fn receive_seeked(&self) -> Result<SeekedStream>
Create a stream that receives Seeked signals.
This a convenient wrapper around zbus::Proxy::receive_signal.
Seeked signal
Indicates that the track position has changed in a way that is inconsistent with the current playing state.
This signal does not need to be emitted when playback starts or when the track changes, unless the track is starting at an unexpected position.
An expected position would be the last known one when going from Paused to Playing, and 0 when going from Stopped to Playing.
Sourcepub async fn receive_seeked_with_args(
&self,
args: &[(u8, &str)],
) -> Result<SeekedStream>
pub async fn receive_seeked_with_args( &self, args: &[(u8, &str)], ) -> Result<SeekedStream>
Create a stream that receives Seeked signals.
This a convenient wrapper around zbus::Proxy::receive_signal_with_args.
Seeked signal
Indicates that the track position has changed in a way that is inconsistent with the current playing state.
This signal does not need to be emitted when playback starts or when the track changes, unless the track is starting at an unexpected position.
An expected position would be the last known one when going from Paused to Playing, and 0 when going from Stopped to Playing.
Sourcepub async fn playback_status(&self) -> Result<PlaybackStatus>
pub async fn playback_status(&self) -> Result<PlaybackStatus>
PlaybackStatus property
Sourcepub fn cached_playback_status(
&self,
) -> Result<Option<<Result<PlaybackStatus> as ResultAdapter>::Ok>, <Result<PlaybackStatus> as ResultAdapter>::Err>
pub fn cached_playback_status( &self, ) -> Result<Option<<Result<PlaybackStatus> as ResultAdapter>::Ok>, <Result<PlaybackStatus> as ResultAdapter>::Err>
PlaybackStatus property
Get the cached value of the PlaybackStatus property, or None if the property is not cached.
Sourcepub async fn receive_playback_status_changed(
&self,
) -> PropertyStream<'p, <Result<PlaybackStatus> as ResultAdapter>::Ok>
pub async fn receive_playback_status_changed( &self, ) -> PropertyStream<'p, <Result<PlaybackStatus> as ResultAdapter>::Ok>
PlaybackStatus property
Create a stream for the PlaybackStatus property changes. This is a convenient wrapper around zbus::Proxy::receive_property_changed.
Sourcepub async fn loop_status(&self) -> Result<LoopStatus>
pub async fn loop_status(&self) -> Result<LoopStatus>
LoopStatus property
Sourcepub fn cached_loop_status(
&self,
) -> Result<Option<<Result<LoopStatus> as ResultAdapter>::Ok>, <Result<LoopStatus> as ResultAdapter>::Err>
pub fn cached_loop_status( &self, ) -> Result<Option<<Result<LoopStatus> as ResultAdapter>::Ok>, <Result<LoopStatus> as ResultAdapter>::Err>
LoopStatus property
Get the cached value of the LoopStatus property, or None if the property is not cached.
Sourcepub async fn receive_loop_status_changed(
&self,
) -> PropertyStream<'p, <Result<LoopStatus> as ResultAdapter>::Ok>
pub async fn receive_loop_status_changed( &self, ) -> PropertyStream<'p, <Result<LoopStatus> as ResultAdapter>::Ok>
LoopStatus property
Create a stream for the LoopStatus property changes. This is a convenient wrapper around zbus::Proxy::receive_property_changed.
pub async fn set_loop_status(&self, value: LoopStatus) -> Result<()>
Sourcepub fn cached_rate(
&self,
) -> Result<Option<<Result<f64> as ResultAdapter>::Ok>, <Result<f64> as ResultAdapter>::Err>
pub fn cached_rate( &self, ) -> Result<Option<<Result<f64> as ResultAdapter>::Ok>, <Result<f64> as ResultAdapter>::Err>
Rate property
Get the cached value of the Rate property, or None if the property is not cached.
Sourcepub async fn receive_rate_changed(
&self,
) -> PropertyStream<'p, <Result<f64> as ResultAdapter>::Ok>
pub async fn receive_rate_changed( &self, ) -> PropertyStream<'p, <Result<f64> as ResultAdapter>::Ok>
Rate property
Create a stream for the Rate property changes. This is a convenient wrapper around zbus::Proxy::receive_property_changed.
pub async fn set_rate(&self, value: f64) -> Result<()>
Sourcepub fn cached_shuffle(
&self,
) -> Result<Option<<Result<bool> as ResultAdapter>::Ok>, <Result<bool> as ResultAdapter>::Err>
pub fn cached_shuffle( &self, ) -> Result<Option<<Result<bool> as ResultAdapter>::Ok>, <Result<bool> as ResultAdapter>::Err>
Shuffle property
Get the cached value of the Shuffle property, or None if the property is not cached.
Sourcepub async fn receive_shuffle_changed(
&self,
) -> PropertyStream<'p, <Result<bool> as ResultAdapter>::Ok>
pub async fn receive_shuffle_changed( &self, ) -> PropertyStream<'p, <Result<bool> as ResultAdapter>::Ok>
Shuffle property
Create a stream for the Shuffle property changes. This is a convenient wrapper around zbus::Proxy::receive_property_changed.
pub async fn set_shuffle(&self, value: bool) -> Result<()>
Sourcepub fn cached_metadata(
&self,
) -> Result<Option<<Result<Metadata> as ResultAdapter>::Ok>, <Result<Metadata> as ResultAdapter>::Err>
pub fn cached_metadata( &self, ) -> Result<Option<<Result<Metadata> as ResultAdapter>::Ok>, <Result<Metadata> as ResultAdapter>::Err>
Metadata property
Get the cached value of the Metadata property, or None if the property is not cached.
Sourcepub async fn receive_metadata_changed(
&self,
) -> PropertyStream<'p, <Result<Metadata> as ResultAdapter>::Ok>
pub async fn receive_metadata_changed( &self, ) -> PropertyStream<'p, <Result<Metadata> as ResultAdapter>::Ok>
Metadata property
Create a stream for the Metadata property changes. This is a convenient wrapper around zbus::Proxy::receive_property_changed.
Sourcepub fn cached_volume(
&self,
) -> Result<Option<<Result<f64> as ResultAdapter>::Ok>, <Result<f64> as ResultAdapter>::Err>
pub fn cached_volume( &self, ) -> Result<Option<<Result<f64> as ResultAdapter>::Ok>, <Result<f64> as ResultAdapter>::Err>
Volume property
Get the cached value of the Volume property, or None if the property is not cached.
Sourcepub async fn receive_volume_changed(
&self,
) -> PropertyStream<'p, <Result<f64> as ResultAdapter>::Ok>
pub async fn receive_volume_changed( &self, ) -> PropertyStream<'p, <Result<f64> as ResultAdapter>::Ok>
Volume property
Create a stream for the Volume property changes. This is a convenient wrapper around zbus::Proxy::receive_property_changed.
pub async fn set_volume(&self, value: f64) -> Result<()>
Sourcepub async fn position(&self) -> Result<MprisDuration>
pub async fn position(&self) -> Result<MprisDuration>
Position property
Sourcepub async fn minimum_rate(&self) -> Result<f64>
pub async fn minimum_rate(&self) -> Result<f64>
MinimumRate property
Sourcepub fn cached_minimum_rate(
&self,
) -> Result<Option<<Result<f64> as ResultAdapter>::Ok>, <Result<f64> as ResultAdapter>::Err>
pub fn cached_minimum_rate( &self, ) -> Result<Option<<Result<f64> as ResultAdapter>::Ok>, <Result<f64> as ResultAdapter>::Err>
MinimumRate property
Get the cached value of the MinimumRate property, or None if the property is not cached.
Sourcepub async fn receive_minimum_rate_changed(
&self,
) -> PropertyStream<'p, <Result<f64> as ResultAdapter>::Ok>
pub async fn receive_minimum_rate_changed( &self, ) -> PropertyStream<'p, <Result<f64> as ResultAdapter>::Ok>
MinimumRate property
Create a stream for the MinimumRate property changes. This is a convenient wrapper around zbus::Proxy::receive_property_changed.
Sourcepub async fn maximum_rate(&self) -> Result<f64>
pub async fn maximum_rate(&self) -> Result<f64>
MaximumRate property
Sourcepub fn cached_maximum_rate(
&self,
) -> Result<Option<<Result<f64> as ResultAdapter>::Ok>, <Result<f64> as ResultAdapter>::Err>
pub fn cached_maximum_rate( &self, ) -> Result<Option<<Result<f64> as ResultAdapter>::Ok>, <Result<f64> as ResultAdapter>::Err>
MaximumRate property
Get the cached value of the MaximumRate property, or None if the property is not cached.
Sourcepub async fn receive_maximum_rate_changed(
&self,
) -> PropertyStream<'p, <Result<f64> as ResultAdapter>::Ok>
pub async fn receive_maximum_rate_changed( &self, ) -> PropertyStream<'p, <Result<f64> as ResultAdapter>::Ok>
MaximumRate property
Create a stream for the MaximumRate property changes. This is a convenient wrapper around zbus::Proxy::receive_property_changed.
Sourcepub async fn can_go_next(&self) -> Result<bool>
pub async fn can_go_next(&self) -> Result<bool>
CanGoNext property
Sourcepub fn cached_can_go_next(
&self,
) -> Result<Option<<Result<bool> as ResultAdapter>::Ok>, <Result<bool> as ResultAdapter>::Err>
pub fn cached_can_go_next( &self, ) -> Result<Option<<Result<bool> as ResultAdapter>::Ok>, <Result<bool> as ResultAdapter>::Err>
CanGoNext property
Get the cached value of the CanGoNext property, or None if the property is not cached.
Sourcepub async fn receive_can_go_next_changed(
&self,
) -> PropertyStream<'p, <Result<bool> as ResultAdapter>::Ok>
pub async fn receive_can_go_next_changed( &self, ) -> PropertyStream<'p, <Result<bool> as ResultAdapter>::Ok>
CanGoNext property
Create a stream for the CanGoNext property changes. This is a convenient wrapper around zbus::Proxy::receive_property_changed.
Sourcepub async fn can_go_previous(&self) -> Result<bool>
pub async fn can_go_previous(&self) -> Result<bool>
CanGoPrevious property
Sourcepub fn cached_can_go_previous(
&self,
) -> Result<Option<<Result<bool> as ResultAdapter>::Ok>, <Result<bool> as ResultAdapter>::Err>
pub fn cached_can_go_previous( &self, ) -> Result<Option<<Result<bool> as ResultAdapter>::Ok>, <Result<bool> as ResultAdapter>::Err>
CanGoPrevious property
Get the cached value of the CanGoPrevious property, or None if the property is not cached.
Sourcepub async fn receive_can_go_previous_changed(
&self,
) -> PropertyStream<'p, <Result<bool> as ResultAdapter>::Ok>
pub async fn receive_can_go_previous_changed( &self, ) -> PropertyStream<'p, <Result<bool> as ResultAdapter>::Ok>
CanGoPrevious property
Create a stream for the CanGoPrevious property changes. This is a convenient wrapper around zbus::Proxy::receive_property_changed.
Sourcepub fn cached_can_play(
&self,
) -> Result<Option<<Result<bool> as ResultAdapter>::Ok>, <Result<bool> as ResultAdapter>::Err>
pub fn cached_can_play( &self, ) -> Result<Option<<Result<bool> as ResultAdapter>::Ok>, <Result<bool> as ResultAdapter>::Err>
CanPlay property
Get the cached value of the CanPlay property, or None if the property is not cached.
Sourcepub async fn receive_can_play_changed(
&self,
) -> PropertyStream<'p, <Result<bool> as ResultAdapter>::Ok>
pub async fn receive_can_play_changed( &self, ) -> PropertyStream<'p, <Result<bool> as ResultAdapter>::Ok>
CanPlay property
Create a stream for the CanPlay property changes. This is a convenient wrapper around zbus::Proxy::receive_property_changed.
Sourcepub fn cached_can_pause(
&self,
) -> Result<Option<<Result<bool> as ResultAdapter>::Ok>, <Result<bool> as ResultAdapter>::Err>
pub fn cached_can_pause( &self, ) -> Result<Option<<Result<bool> as ResultAdapter>::Ok>, <Result<bool> as ResultAdapter>::Err>
CanPause property
Get the cached value of the CanPause property, or None if the property is not cached.
Sourcepub async fn receive_can_pause_changed(
&self,
) -> PropertyStream<'p, <Result<bool> as ResultAdapter>::Ok>
pub async fn receive_can_pause_changed( &self, ) -> PropertyStream<'p, <Result<bool> as ResultAdapter>::Ok>
CanPause property
Create a stream for the CanPause property changes. This is a convenient wrapper around zbus::Proxy::receive_property_changed.
Sourcepub fn cached_can_seek(
&self,
) -> Result<Option<<Result<bool> as ResultAdapter>::Ok>, <Result<bool> as ResultAdapter>::Err>
pub fn cached_can_seek( &self, ) -> Result<Option<<Result<bool> as ResultAdapter>::Ok>, <Result<bool> as ResultAdapter>::Err>
CanSeek property
Get the cached value of the CanSeek property, or None if the property is not cached.
Sourcepub async fn receive_can_seek_changed(
&self,
) -> PropertyStream<'p, <Result<bool> as ResultAdapter>::Ok>
pub async fn receive_can_seek_changed( &self, ) -> PropertyStream<'p, <Result<bool> as ResultAdapter>::Ok>
CanSeek property
Create a stream for the CanSeek property changes. This is a convenient wrapper around zbus::Proxy::receive_property_changed.
Sourcepub async fn can_control(&self) -> Result<bool>
pub async fn can_control(&self) -> Result<bool>
CanControl property