2015-09-10 14:38:16 +00:00
|
|
|
use std::io::BufReader;
|
2016-10-04 14:36:11 +00:00
|
|
|
use std::thread;
|
|
|
|
use std::time::Duration;
|
2015-09-10 14:38:16 +00:00
|
|
|
|
2015-07-22 10:14:11 +00:00
|
|
|
fn main() {
|
2020-02-25 10:09:17 +00:00
|
|
|
let (_stream, stream_handle) = rodio::OutputStream::try_default().unwrap();
|
2015-09-01 17:35:26 +00:00
|
|
|
|
2015-07-22 10:14:11 +00:00
|
|
|
let file = std::fs::File::open("examples/beep.wav").unwrap();
|
2020-02-25 10:09:17 +00:00
|
|
|
let beep1 = stream_handle.play_once(BufReader::new(file)).unwrap();
|
2015-09-11 11:49:07 +00:00
|
|
|
beep1.set_volume(0.2);
|
2017-02-07 11:33:18 +00:00
|
|
|
println!("Started beep1");
|
2015-07-22 10:14:11 +00:00
|
|
|
|
2017-02-07 11:33:18 +00:00
|
|
|
thread::sleep(Duration::from_millis(1500));
|
2015-07-22 11:27:53 +00:00
|
|
|
|
|
|
|
let file = std::fs::File::open("examples/beep2.wav").unwrap();
|
2020-02-25 10:09:17 +00:00
|
|
|
let beep2 = stream_handle.play_once(BufReader::new(file)).unwrap();
|
2020-02-08 14:25:21 +00:00
|
|
|
beep2.set_volume(0.3);
|
|
|
|
beep2.detach();
|
2017-02-07 11:33:18 +00:00
|
|
|
println!("Started beep2");
|
2015-07-22 10:14:11 +00:00
|
|
|
|
2017-02-07 11:33:18 +00:00
|
|
|
thread::sleep(Duration::from_millis(1500));
|
2015-09-10 15:52:02 +00:00
|
|
|
let file = std::fs::File::open("examples/beep3.ogg").unwrap();
|
2020-02-25 10:09:17 +00:00
|
|
|
let beep3 = stream_handle.play_once(file).unwrap();
|
2020-02-08 14:25:21 +00:00
|
|
|
beep3.set_volume(0.2);
|
2017-02-07 11:33:18 +00:00
|
|
|
println!("Started beep3");
|
2015-07-22 12:23:03 +00:00
|
|
|
|
2017-02-07 11:33:18 +00:00
|
|
|
thread::sleep(Duration::from_millis(1500));
|
2015-10-16 13:40:30 +00:00
|
|
|
drop(beep1);
|
2017-02-07 11:33:18 +00:00
|
|
|
println!("Stopped beep1");
|
2015-07-22 11:27:53 +00:00
|
|
|
|
2017-02-07 11:33:18 +00:00
|
|
|
thread::sleep(Duration::from_millis(1500));
|
2015-10-16 13:40:30 +00:00
|
|
|
drop(beep3);
|
2017-02-07 11:33:18 +00:00
|
|
|
println!("Stopped beep3");
|
2015-09-27 12:49:53 +00:00
|
|
|
|
2017-02-07 11:33:18 +00:00
|
|
|
thread::sleep(Duration::from_millis(1500));
|
2015-07-22 10:14:11 +00:00
|
|
|
}
|