rodio
rodio copied to clipboard
Skipping Samples from Decoder
Is there any way to skip over audio samples using radio?
I tried to seek the BufReader forward but that results in an UnrecognizedFormat error.
The only way I've found that works requires reading the full file into memory:
let sample_rate = decoder.sample_rate();
let channels = decoder.channels();
let source = decoder.skip((sample_rate * 10) as usize).collect::<Vec<i16>>(); // decode the full song
sink.append(rodio::buffer::SamplesBuffer::new(channels, sample_rate, source));
Shouldn't be that difficult to implement, as far as I can tell. Isn't that just basically the thing skip() does for iterators, maybe with a little bit extra logic for the total duration (the last of the Source trait functions)?