2015-07-22 10:14:11 +00:00
|
|
|
extern crate rodio;
|
|
|
|
|
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() {
|
2018-04-18 19:23:40 +00:00
|
|
|
let device = rodio::default_output_device().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();
|
2018-04-18 19:23:40 +00:00
|
|
|
let mut beep1 = rodio::play_once(&device, 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();
|
2018-04-18 19:23:40 +00:00
|
|
|
rodio::play_once(&device, BufReader::new(file))
|
2017-05-04 11:51:33 +00:00
|
|
|
.unwrap()
|
|
|
|
.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();
|
2018-04-18 19:23:40 +00:00
|
|
|
let beep3 = rodio::play_once(&device, file).unwrap();
|
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
|
|
|
}
|