rodio icon indicating copy to clipboard operation
rodio copied to clipboard

Skipping Samples from Decoder

Open Capital-EX opened this issue 7 years ago • 1 comments

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

Capital-EX avatar May 22 '18 15:05 Capital-EX

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)?

AntonHermann avatar Sep 21 '18 16:09 AntonHermann