Struct rusty_audio::Audio[][src]

pub struct Audio { /* fields omitted */ }

A simple 4-track audio system to load/decode audio files from disk to play later. Supported formats are: MP3, WAV, Vorbis and Flac.

Implementations

impl Audio[src]

pub fn new() -> Self[src]

Create a new sound subsystem. You only need one of these – you can use it to load and play any number of audio clips.

pub fn disabled(&self) -> bool[src]

If no sound device was detected, the audio subsystem will run in a disabled mode that doesn’t actually do anything. This method indicates whether audio is disabled.

pub fn add(&mut self, name: &'static str, path: &str)[src]

Add an audio clip to play. Audio clips will be decoded and buffered during this call so the first call to .play() is not staticky if you compile in debug mode. name is what you will refer to this clip as when you need to play it. Files known to be supported by the underlying library (rodio) at the time of this writing are MP3, WAV, Vorbis and Flac.

pub fn play(&mut self, name: &str)[src]

Play an audio clip that has already been loaded. name is the name you chose when you added the clip to the Audio system. If you forgot to load the clip first, this will crash.

pub fn wait(&self)[src]

Block until no sounds are playing. Convenient for keeping a thread alive until all sounds have played.

Trait Implementations

impl Default for Audio[src]

Auto Trait Implementations

impl !RefUnwindSafe for Audio

impl !Send for Audio

impl !Sync for Audio

impl Unpin for Audio

impl !UnwindSafe for Audio

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.