pub struct AudioClip {
pub state: AudioPlayState,
pub looping: bool,
pub volume: f64,
pub playback_rate: f64,
/* private fields */
}Expand description
An audio clip wrapping a decoded AudioBuffer with playback control.
Fields§
§state: AudioPlayStateThe current playback state.
get_state is public because tests/audio_clip/fn.rs reads this field from
outside this crate. get_mut / set stay crate-internal.
looping: boolWhether the clip should loop when it reaches the end.
get_looping is public because tests/audio_clip/fn.rs reads this field from
outside this crate. get_mut / set stay crate-internal.
volume: f64The volume level in the range 0.0 to 1.0.
get_volume is public because tests/audio_clip/fn.rs reads this field from
outside this crate. get_mut / set stay crate-internal.
playback_rate: f64The playback rate multiplier (1.0 = normal speed).
get_playback_rate is public because tests/audio_clip/fn.rs reads this field from
outside this crate. get_mut / set stay crate-internal.
Implementations§
Source§impl AudioClip
Implements playback control for AudioClip.
impl AudioClip
Implements playback control for AudioClip.
Sourcepub fn create(buffer: AudioBuffer) -> AudioClip
pub fn create(buffer: AudioBuffer) -> AudioClip
Creates a new audio clip from a decoded buffer.
A clip carries no name: playback is driven by play / stop, which
address a clip by identity rather than by label, so a name field would
only ever be stored and never read.
§Arguments
AudioBuffer- The decoded audio data.
§Returns
AudioClip- The new clip.
Sourcepub fn play(&mut self, audio_context: &GameAudioContext)
pub fn play(&mut self, audio_context: &GameAudioContext)
Plays this clip through the given audio context.
Creates a new AudioBufferSourceNode, connects it through a gain node
to the master gain, and starts playback. If already playing, does nothing.
§Arguments
&GameAudioContext- The audio context to play through.