1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
extern crate ears;
use std::time::Duration;
use std::thread::sleep;
use ears::{Sound, Music, AudioController};
pub fn play(s: &str) {
let mut snd = Sound::new(s).unwrap();
snd.play();
while snd.is_playing() {}
}
pub fn play_music(s: &str) {
let mut music = Music::new(s).unwrap();
music.play();
while music.is_playing() {
sleep(Duration::from_millis(1000));
}
}