Progress

Struct Progress 

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

Struct containing information about current progress of a Player.

It has access to the metadata of the current track, as well as information about the current position of the track.

It is up to you to decide on how outdated information you want to rely on when implementing progress rendering.

Implementations§

Source§

impl Progress

Source

pub fn metadata(&self) -> &Metadata

The track metadata at the point in time that this Progress was constructed.

Source

pub fn playback_status(&self) -> PlaybackStatus

The playback status at the point in time that this Progress was constructed.

Source

pub fn shuffle(&self) -> bool

The shuffle status at the point in time that this Progress was constructed.

Source

pub fn loop_status(&self) -> LoopStatus

The loop status at the point in time that this Progress was constructed.

Source

pub fn playback_rate(&self) -> f64

The playback rate at the point in time that this Progress was constructed.

Source

pub fn length(&self) -> Option<Duration>

Returns the length of the current track as a Duration.

Source

pub fn position(&self) -> Duration

Returns the current position of the current track as a Duration.

This method will calculate the expected position of the track at the instant of the invocation using the initial_position and knowledge of how long ago that position was determined.

Note: Some players might not support this and will return a bad position. Spotify is one such example. There is no reliable way of detecting problematic players, so it will be up to your client to check for this.

One way of doing this is to query the initial_position for two measures with the PlaybackStatus::Playing and if both are 0, then it is likely that this client does not support positions.

Source

pub fn initial_position(&self) -> Duration

Returns the position that the current track was at when the Progress was created.

This is the number that was returned for the Position property in the MPRIS2 interface.

Source

pub fn created_at(&self) -> &Instant

The instant where this Progress was recorded.

See: age.

Source

pub fn age(&self) -> Duration

Returns the age of the data as a Duration.

If the Progress has a high age it is more likely to be out of date.

Source

pub fn current_volume(&self) -> f64

Returns the player’s volume as it was at the time of refresh.

See: Player::get_volume.

Trait Implementations§

Source§

impl Debug for Progress

Source§

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

Formats the value using the given formatter. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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