Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::process::Command;
- use std::fs::DirEntry;
- pub struct Audio {
- pub name: String,
- pub duration: String,
- }
- impl Audio {
- pub fn get_length (audio: DirEntry) -> Audio {
- let cmd = Command::new("soxi")
- .args(["-D", &audio.path().to_string_lossy()]).output()
- .expect("soxi -D failed");
- let duration = String::from_utf8_lossy(&cmd.stdout)
- .to_string().split('\n')
- .collect::<String>();
- Audio {
- name: audio.file_name().to_string_lossy().to_string(),
- duration
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement