pub struct AudioBuilder { /* private fields */ }Expand description
Used to play an audio file or tone and create an Audio instance.
Implementations§
Source§impl AudioBuilder
impl AudioBuilder
Sourcepub fn new(audio_type: &AudioType) -> Self
pub fn new(audio_type: &AudioType) -> Self
Create a new AudioBuilder with a certain AudioType, which describes either an
audio file or a tone.
Sourcepub fn name<T: AsRef<str>>(self, name: T) -> Self
pub fn name<T: AsRef<str>>(self, name: T) -> Self
Set the name of the audio instance. Each audio instance should have a unique name.
By default, a unique name is created for each audio instance. Setting a custom name is not recommended.
Sourcepub fn volume(self, volume: f64) -> Self
pub fn volume(self, volume: f64) -> Self
Set the volume of the audio instance.
By default, the volume is 1.0.
Sourcepub fn does_loop(self, does_loop: bool) -> Self
pub fn does_loop(self, does_loop: bool) -> Self
Set whether the audio instance loops.
By default, the audio instance does not loop.
Sourcepub fn loop_count(self, loop_count: i64) -> Self
pub fn loop_count(self, loop_count: i64) -> Self
Set the number of times to loop.
does_loop should be used to allow looping of the audio instance.
By default, the audio instance loops forever.
Sourcepub fn build(&self) -> AudioResult<Audio>
pub fn build(&self) -> AudioResult<Audio>
Play the audio instance and return an Audio struct, which can be used to get or
update properties of the audio instance.
This can be called multiple times to play a certain audio multiple times. This will block until the audio instance begins playing.