Struct Audio

Source
pub struct Audio {}
Expand description

A interface of an audio player.

Implementations§

Source§

impl Audio

Source

pub fn play(filename: &str, looping: bool) -> i32

Plays a sound effect and returns a handler for the audio.

§Arguments
  • filename - The path to the sound effect file (must be a WAV file).
  • loop - Optional. Whether to loop the sound effect. Default is false.
§Returns
  • i32 - A handler for the audio that can be used to stop the sound effect.
Source

pub fn stop(handle: i32)

Stops a sound effect that is currently playing.

§Arguments
  • handler - The handler for the audio that is returned by the play function.
Source

pub fn play_stream(filename: &str, looping: bool, cross_fade_time: f32)

Plays a streaming audio file.

§Arguments
  • filename - The path to the streaming audio file (can be OGG, WAV, MP3, or FLAC).
  • loop - Whether to loop the streaming audio.
  • crossFadeTime - The time (in seconds) to crossfade between the previous and new streaming audio.
Source

pub fn stop_stream(fade_time: f32)

Stops a streaming audio file that is currently playing.

§Arguments
  • fade_time - The time (in seconds) to fade out the streaming audio.

Auto Trait Implementations§

§

impl Freeze for Audio

§

impl RefUnwindSafe for Audio

§

impl Send for Audio

§

impl Sync for Audio

§

impl Unpin for Audio

§

impl UnwindSafe for Audio

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.