rodio/examples/seek_mp3.rs
dvdsk fb44f71dc9
Fixes seek example and various spell/grammar issues
Co-authored-by: naglis <827324+naglis@users.noreply.github.com>
2024-01-31 14:53:10 +01:00

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();
}