rodio
rodio copied to clipboard
Calculate duration for mp3s
Currently, the duration is not calculated for mp3s when using symphonia
Will someone please merge this.
First off all, sorry this took a while we are short on maintainers. Thanks for making a PR though! Part of what you did in this PR overlaps with #513 (which has been merged).
This:
use std::io::BufReader;
use rodio::Source;
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();
let source = rodio::Decoder::new(BufReader::new(file)).unwrap();
dbg!(source.total_duration());
sink.append(source);
sink.sleep_until_end();
}
prints:
[examples/music_mp3.rs:11:5] source.total_duration() = Some(
10.000000006s,
)
Which is correct for the music.mp3 test file.
And that's good news! That means we get a duration for mp3 files without introducing the overhead of implementing bytes_len().
@kuviman if I am wrong and total_duration is not working for you on the latest master branch commit please reopen this or let me known in some other way!