Skip to main content

Player

Struct Player 

Source
pub struct Player { /* private fields */ }
Expand description

Simplified access to the controls of an MPRIS media player.

Implementations§

Source§

impl Player

Source

pub async fn new(connection: &Connection, name: OwnedBusName) -> Result<Self>

Creates a new instance of the org.mpris.MediaPlayer2.Player interface.

Source

pub async fn media_player(&self) -> Result<MediaPlayer>

Returns this player’s org.mpris.MediaPlayer2 instance

Source

pub async fn seek<D>(&self, duration: D) -> Result<bool>
where D: Into<MprisDuration>,

Seeks the specified duration.

Source

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”.

Source

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.

Source

pub async fn playback_status(&self) -> Result<PlaybackStatus>

Gets the current playback status of the player.

Source

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.

Source

pub async fn set_rate(&self, value: f64) -> Result<()>

Sets the current rate of playback.

Source

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.

Source

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.

Source

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.

Source

pub async fn metadata(&self) -> Result<Metadata>

Returns the metadata for the player.

Source

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.

Source

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.

Source

pub async fn loop_status(&self) -> Result<Option<LoopStatus>>

The current loop / repeat status.

Source

pub async fn set_loop_status(&self, value: LoopStatus) -> Result<()>

Set the current loop / repeat status.

Methods from Deref<Target = PlayerProxy<'static>>§

Source

pub fn inner(&self) -> &Proxy<'p>

The reference to the underlying zbus::Proxy.

Source

pub async fn next(&self) -> Result<()>

Next method

Source

pub async fn previous(&self) -> Result<()>

Previous method

Source

pub async fn pause(&self) -> Result<()>

Pause method

Source

pub async fn play_pause(&self) -> Result<()>

PlayPause method

Source

pub async fn stop(&self) -> Result<()>

Stop method

Source

pub async fn play(&self) -> Result<()>

Play method

Source

pub async fn seek(&self, offset: MprisDuration) -> Result<()>

Seek method

Source

pub async fn set_position( &self, track_id: TrackId, position: MprisDuration, ) -> Result<()>

SetPosition method

Source

pub async fn open_uri(&self, uri: &str) -> Result<()>

OpenUri method

Source

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.

Source

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.

Source

pub async fn playback_status(&self) -> Result<PlaybackStatus>

PlaybackStatus property

Source

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.

Source

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.

Source

pub async fn loop_status(&self) -> Result<LoopStatus>

LoopStatus property

Source

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.

Source

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.

Source

pub async fn set_loop_status(&self, value: LoopStatus) -> Result<()>

Source

pub async fn rate(&self) -> Result<f64>

Rate property

Source

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.

Source

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.

Source

pub async fn set_rate(&self, value: f64) -> Result<()>

Source

pub async fn shuffle(&self) -> Result<bool>

Shuffle property

Source

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.

Source

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.

Source

pub async fn set_shuffle(&self, value: bool) -> Result<()>

Source

pub async fn metadata(&self) -> Result<Metadata>

Metadata property

Source

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.

Source

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.

Source

pub async fn volume(&self) -> Result<f64>

Volume property

Source

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.

Source

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.

Source

pub async fn set_volume(&self, value: f64) -> Result<()>

Source

pub async fn position(&self) -> Result<MprisDuration>

Position property

Source

pub async fn minimum_rate(&self) -> Result<f64>

MinimumRate property

Source

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.

Source

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.

Source

pub async fn maximum_rate(&self) -> Result<f64>

MaximumRate property

Source

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.

Source

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.

Source

pub async fn can_go_next(&self) -> Result<bool>

CanGoNext property

Source

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.

Source

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.

Source

pub async fn can_go_previous(&self) -> Result<bool>

CanGoPrevious property

Source

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.

Source

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.

Source

pub async fn can_play(&self) -> Result<bool>

CanPlay property

Source

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.

Source

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.

Source

pub async fn can_pause(&self) -> Result<bool>

CanPause property

Source

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.

Source

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.

Source

pub async fn can_seek(&self) -> Result<bool>

CanSeek property

Source

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.

Source

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.

Source

pub async fn can_control(&self) -> Result<bool>

CanControl property

Trait Implementations§

Source§

impl Clone for Player

Source§

fn clone(&self) -> Player

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Player

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for Player

Source§

type Target = PlayerProxy<'static>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl From<PlayerProxy<'static>> for Player

Source§

fn from(proxy: PlayerProxy<'static>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more