Function macroquad::audio::load_sound
source · pub async fn load_sound(path: &str) -> Result<Sound, Error>
Expand description
Load audio file.
Attempts to automatically detect the format of the source of data.
Examples found in repository?
examples/audio.rs (line 7)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
async fn main() {
set_pc_assets_folder("examples");
let sound1 = audio::load_sound("sound.wav").await.unwrap();
let sound2 = audio::load_sound("sound2.wav").await.unwrap();
loop {
clear_background(LIGHTGRAY);
if ui::root_ui().button(None, "Play sound 1") {
warn!("play 1!");
audio::play_sound_once(&sound1);
}
if ui::root_ui().button(None, "Play sound 2") {
warn!("play 2!");
audio::play_sound_once(&sound2);
}
next_frame().await
}
}