pub trait Sound: Asset {
fn duration(&self) -> f32;
fn play(&self, volume: f32) -> Rc<dyn Playback + 'static>;
fn play_with_loop(&self, volume: f32) -> Rc<dyn Playback + 'static>;
}
Expand description
A loaded sound file.
Required Methods
Plays the sound once, suitable for one-shot sound effects.
@param volume The playback volume between 0 (silence) and 1 (full volume). Defaults to 1. @returns A playback that can be used to control the sound.
fn play_with_loop(&self, volume: f32) -> Rc<dyn Playback + 'static>
fn play_with_loop(&self, volume: f32) -> Rc<dyn Playback + 'static>
Loops the sound forever, suitable for background music.
@param volume The playback volume between 0 (silence) and 1 (full volume). Defaults to 1. @returns A playback that can be used to control the sound.