rodio/examples/music_mp3.rs
2024-11-20 00:58:05 +04:00

14 lines
392 B
Rust

use std::error::Error;
use std::io::BufReader;
fn main() -> Result<(), Box<dyn Error>> {
let stream_handle = rodio::OutputStreamBuilder::try_default_stream()?;
let sink = rodio::Sink::connect_new(&stream_handle.mixer());
let file = std::fs::File::open("assets/music.mp3")?;
sink.append(rodio::Decoder::new(BufReader::new(file))?);
sink.sleep_until_end();
Ok(())
}