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();
|
|
|
|
|
|
|
|
let file = std::fs::File::open("examples/music.mp3").unwrap();
|
2021-01-13 22:31:05 +00:00
|
|
|
sink.append_seekable(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));
|
|
|
|
sink.seek(Duration::from_secs(0));
|
|
|
|
|
|
|
|
std::thread::sleep(std::time::Duration::from_secs(2));
|
|
|
|
sink.seek(Duration::from_secs(4));
|
2021-01-02 23:40:54 +00:00
|
|
|
|
|
|
|
sink.sleep_until_end();
|
|
|
|
}
|