Struct rodio::Sink

source ·
pub struct Sink { /* private fields */ }
Expand description

Handle to a device that outputs sounds.

Dropping the Sink stops all sounds. You can use detach if you want the sounds to continue playing.

Implementations§

source§

impl Sink

source

pub fn try_new(stream: &OutputStreamHandle) -> Result<Sink, PlayError>

Builds a new Sink, beginning playback on a stream.

source

pub fn new_idle() -> (Sink, SourcesQueueOutput<f32>)

Builds a new Sink.

source

pub fn append<S>(&self, source: S)
where S: Source + Send + 'static, f32: FromSample<S::Item>, S::Item: Sample + Send,

Appends a sound to the queue of sounds to play.

source

pub fn volume(&self) -> f32

Gets the volume of the sound.

The value 1.0 is the “normal” volume (unfiltered input). Any value other than 1.0 will multiply each sample by this value.

source

pub fn set_volume(&self, value: f32)

Changes the volume of the sound.

The value 1.0 is the “normal” volume (unfiltered input). Any value other than 1.0 will multiply each sample by this value.

source

pub fn speed(&self) -> f32

Gets the speed of the sound.

The value 1.0 is the “normal” speed (unfiltered input). Any value other than 1.0 will change the play speed of the sound.

source

pub fn set_speed(&self, value: f32)

Changes the speed of the sound.

The value 1.0 is the “normal” speed (unfiltered input). Any value other than 1.0 will change the play speed of the sound.

source

pub fn play(&self)

Resumes playback of a paused sink.

No effect if not paused.

source

pub fn pause(&self)

Pauses playback of this sink.

No effect if already paused.

A paused sink can be resumed with play().

source

pub fn is_paused(&self) -> bool

Gets if a sink is paused

Sinks can be paused and resumed using pause() and play(). This returns true if the sink is paused.

source

pub fn clear(&self)

Removes all currently loaded Sources from the Sink, and pauses it.

See pause() for information about pausing a Sink.

source

pub fn skip_one(&self)

Skips to the next Source in the Sink

If there are more Sources appended to the Sink at the time, it will play the next one. Otherwise, the Sink will finish as if it had finished playing a Source all the way through.

source

pub fn stop(&self)

Stops the sink by emptying the queue.

source

pub fn detach(self)

Destroys the sink without stopping the sounds that are still playing.

source

pub fn sleep_until_end(&self)

Sleeps the current thread until the sound ends.

source

pub fn empty(&self) -> bool

Returns true if this sink has no more sounds to play.

source

pub fn len(&self) -> usize

Returns the number of sounds currently in the queue.

Trait Implementations§

source§

impl Drop for Sink

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Sink

§

impl Send for Sink

§

impl Sync for Sink

§

impl Unpin for Sink

§

impl UnwindSafe for Sink

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

§

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

§

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,