hint from file extension
This commit is contained in:
parent
9130f52f66
commit
fe1ee27d80
2 changed files with 19 additions and 3 deletions
|
@ -18,7 +18,7 @@ thiserror = "2.0"
|
||||||
derive-new = "0.7"
|
derive-new = "0.7"
|
||||||
strum = { version = "0.26", features = ["derive"] }
|
strum = { version = "0.26", features = ["derive"] }
|
||||||
derive_wrapper = "0.1"
|
derive_wrapper = "0.1"
|
||||||
symphonia = { version = "0.5.4", features = ["all"] }
|
symphonia = { version = "0.5", features = ["all"] }
|
||||||
|
|
||||||
[dev_dependencies]
|
[dev_dependencies]
|
||||||
project-root = "0.2.2"
|
project-root = "0.2.2"
|
||||||
|
|
|
@ -58,7 +58,13 @@ impl Audio {
|
||||||
let mss = MediaSourceStream::new(Box::new(mediasource), Default::default());
|
let mss = MediaSourceStream::new(Box::new(mediasource), Default::default());
|
||||||
let reader = probe
|
let reader = probe
|
||||||
.format(
|
.format(
|
||||||
&Default::default(),
|
&Hint::new().with_extension(
|
||||||
|
path.as_ref()
|
||||||
|
.extension()
|
||||||
|
.map(|os_str| os_str.to_str())
|
||||||
|
.flatten()
|
||||||
|
.unwrap_or("mp3"),
|
||||||
|
),
|
||||||
mss,
|
mss,
|
||||||
&Default::default(),
|
&Default::default(),
|
||||||
&Default::default(),
|
&Default::default(),
|
||||||
|
@ -179,6 +185,16 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn open_sample_file() {
|
fn open_sample_file() {
|
||||||
assert_eq!(Ok(include_bytes!("../../../testing material/sound/1938-04-30_BBC_Winston_Churchill_To_The_Royal_Academy_Of_Arts.mp3").to_vec()), Audio::open(get_project_root().expect("can't find project root!").join("testing material").join("sound").join("1938-04-30_BBC_Winston_Churchill_To_The_Royal_Academy_Of_Arts.mp3")).map(|audio| audio.into_data_bytes()));
|
assert_eq!(
|
||||||
|
Ok(include_bytes!("../../../testing material/sound/sample-3s.mp3").to_vec()),
|
||||||
|
Audio::open(
|
||||||
|
get_project_root()
|
||||||
|
.expect("can't find project root!")
|
||||||
|
.join("testing material")
|
||||||
|
.join("sound")
|
||||||
|
.join("sample-3s.mp3")
|
||||||
|
)
|
||||||
|
.map(|audio| audio.into_data_bytes())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue