1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-01-02 17:08:50 +00:00
comunicapiv3/src/utils/mp3_utils.rs

16 lines
382 B
Rust
Raw Normal View History

2021-03-06 08:35:36 +00:00
//! # MP3 utilities
//!
//! @author Pierre Hubert
/// Check out whether a file is a valid MP3 file or not
pub fn is_valid_mp3(file: &[u8]) -> bool {
let res = mp3_metadata::read_from_slice(file);
match res {
2021-03-06 08:49:47 +00:00
Ok(e) => e.duration.as_secs() > 0,
2021-03-06 08:35:36 +00:00
Err(e) => {
eprintln!("Error while parsing MP3 file ! {:#?}", e);
false
}
}
}