Skip to main content

AudioPlayer

Struct AudioPlayer 

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

Incremental decoded PCM playback through the default output device.

Implementations§

Source§

impl AudioPlayer

Source

pub fn open(runtime: &Runtime, config: AudioPlayerConfig) -> Result<Self>

Open the source and default output device with decoding initially paused.

§Errors

Returns an error for an empty URI, a ring outside 40–5000 ms, or when the selected audio track and output device cannot be opened.

Source

pub fn new_from_uri(runtime: &Runtime, uri: impl AsRef<Path>) -> Result<Self>

Open a URI using the default playback configuration.

Source

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

Start or resume playback, rewinding after end-of-stream.

Source

pub fn pause(&self)

Pause playback without disturbing decoder position.

Source

pub fn seek(&mut self, timestamp_us: u64) -> Result<()>

Seek to a timestamp in microseconds and wait for decoder acknowledgement.

Source

pub fn set_loop(&self, enabled: bool)

Source

pub fn set_muted(&self, muted: bool) -> Result<()>

Source

pub fn close(&mut self) -> Result<()>

Stop decoding and release the device at an explicit result-bearing boundary.

Source

pub const fn is_open(&self) -> bool

Source

pub fn is_playing(&self) -> bool

Source

pub fn is_eos(&self) -> bool

Source

pub fn is_muted(&self) -> bool

Source

pub const fn sample_rate(&self) -> u32

Source

pub const fn channel_count(&self) -> u32

Source

pub const fn duration_us(&self) -> u64

Source

pub fn position_us(&self) -> u64

Source

pub fn underrun_frame_count(&self) -> u64

Source

pub fn device_error_count(&self) -> u64

Trait Implementations§

Source§

impl Drop for AudioPlayer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.