mirror of
https://github.com/RustAudio/rodio
synced 2024-11-13 23:47:11 +00:00
fb44f71dc9
Co-authored-by: naglis <827324+naglis@users.noreply.github.com>
18 lines
580 B
Rust
18 lines
580 B
Rust
use std::io::BufReader;
|
|
use std::time::Duration;
|
|
|
|
fn main() {
|
|
let (_stream, handle) = rodio::OutputStream::try_default().unwrap();
|
|
let sink = rodio::Sink::try_new(&handle).unwrap();
|
|
|
|
let file = std::fs::File::open("assets/music.mp3").unwrap();
|
|
sink.append(rodio::Decoder::new(BufReader::new(file)).unwrap());
|
|
|
|
std::thread::sleep(std::time::Duration::from_secs(2));
|
|
sink.try_seek(Duration::from_secs(0)).unwrap();
|
|
|
|
std::thread::sleep(std::time::Duration::from_secs(2));
|
|
sink.try_seek(Duration::from_secs(4)).unwrap();
|
|
|
|
sink.sleep_until_end();
|
|
}
|