rodio/examples/music_mp3.rs

13 lines
387 B
Rust
Raw Normal View History

2018-05-26 23:39:03 +00:00
use std::io::BufReader;
fn main() {
2024-11-09 22:34:49 +00:00
let stream_handle = rodio::OutputStreamBuilder::try_default_stream()
.expect("open default audio stream");
let sink = rodio::Sink::connect_new(&stream_handle.mixer());
2018-05-26 23:39:03 +00:00
let file = std::fs::File::open("assets/music.mp3").unwrap();
2018-05-26 23:39:03 +00:00
sink.append(rodio::Decoder::new(BufReader::new(file)).unwrap());
sink.sleep_until_end();
}