use audex::StreamInfo;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let filter = std::env::var("RUST_LOG").unwrap_or_else(|_| "audex=debug".to_string());
tracing_subscriber::fmt()
.with_env_filter(filter)
.with_target(true)
.with_thread_ids(false)
.with_file(false)
.with_line_number(false)
.init();
let path = match std::env::args().nth(1) {
Some(p) => p,
None => {
eprintln!("Usage: tracing_debug <audio-file>");
eprintln!(" RUST_LOG=audex=trace tracing_debug <audio-file>");
std::process::exit(1);
}
};
println!("--- Loading: {} ---", path);
let file = audex::File::load(&path)?;
println!("\nFormat : {}", file.format_name());
println!("Tags : {}", if file.has_tags() { "yes" } else { "no" });
if let Some(info) = file.info().length() {
println!("Length : {:.2}s", info.as_secs_f64());
}
let keys = file.keys();
if !keys.is_empty() {
println!("\nTag keys ({}):", keys.len());
for key in &keys {
if let Some(values) = file.get(key) {
println!(" {} = {:?}", key, values);
}
}
}
Ok(())
}