blob: 8a3395a3738e167f0872613db45d45bf0766662d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
use std::time::Duration;
use rodio::{source::SineWave, OutputStream, Sink, Source};
fn main() {
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
let sink = Sink::try_new(&stream_handle).unwrap();
// Add a dummy source of the sake of the example.
let source = SineWave::new(440)
.take_duration(Duration::from_secs_f32(0.25))
.amplify(0.20);
sink.append(source);
// The sound plays in a separate thread. This call will block the current thread until the sink
// has finished playing all its queued sounds.
sink.sleep_until_end();
}
|