rodio/examples/music_mp3.rs
2024-11-10 02:34:49 +04:00

12 lines
387 B
Rust

use std::io::BufReader;
fn main() {
let stream_handle = rodio::OutputStreamBuilder::try_default_stream()
.expect("open default audio stream");
let sink = rodio::Sink::connect_new(&stream_handle.mixer());
let file = std::fs::File::open("assets/music.mp3").unwrap();
sink.append(rodio::Decoder::new(BufReader::new(file)).unwrap());
sink.sleep_until_end();
}