2021-01-02 23:40:54 +00:00
|
|
|
use std::io::BufReader;
|
2023-09-30 19:53:56 +00:00
|
|
|
use std::time::Duration;
|
2021-01-02 23:40:54 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let (_stream, handle) = rodio::OutputStream::try_default().unwrap();
|
|
|
|
let sink = rodio::Sink::try_new(&handle).unwrap();
|
|
|
|
|
2024-01-31 13:53:10 +00:00
|
|
|
let file = std::fs::File::open("assets/music.mp3").unwrap();
|
2023-10-02 22:31:42 +00:00
|
|
|
sink.append(rodio::Decoder::new(BufReader::new(file)).unwrap());
|
2021-01-02 23:40:54 +00:00
|
|
|
|
2023-09-30 19:53:56 +00:00
|
|
|
std::thread::sleep(std::time::Duration::from_secs(2));
|
2023-10-02 22:31:42 +00:00
|
|
|
sink.try_seek(Duration::from_secs(0)).unwrap();
|
2023-09-30 19:53:56 +00:00
|
|
|
|
|
|
|
std::thread::sleep(std::time::Duration::from_secs(2));
|
2023-10-02 22:31:42 +00:00
|
|
|
sink.try_seek(Duration::from_secs(4)).unwrap();
|
2021-01-02 23:40:54 +00:00
|
|
|
|
|
|
|
sink.sleep_until_end();
|
|
|
|
}
|