@@ -9,7 +9,36 @@ use crate::sound::{
9
9
use super :: StaticSoundData ;
10
10
11
11
impl StaticSoundData {
12
- fn from_media_source (
12
+ /// Loads an audio file into a [`StaticSoundData`].
13
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
14
+ #[ cfg_attr( docsrs, doc( cfg( all( feature = "symphonia" , not( wasm32) ) ) ) ) ]
15
+ pub fn from_file (
16
+ path : impl AsRef < std:: path:: Path > ,
17
+ settings : StaticSoundSettings ,
18
+ ) -> Result < Self , FromFileError > {
19
+ Self :: from_media_source ( std:: fs:: File :: open ( path) ?, settings)
20
+ }
21
+
22
+ /// Loads a cursor wrapping audio file data into a [`StaticSoundData`].
23
+ #[ cfg_attr( docsrs, doc( cfg( feature = "symphonia" ) ) ) ]
24
+ pub fn from_cursor < T : AsRef < [ u8 ] > + Send + Sync + ' static > (
25
+ cursor : Cursor < T > ,
26
+ settings : StaticSoundSettings ,
27
+ ) -> Result < StaticSoundData , FromFileError > {
28
+ Self :: from_media_source ( cursor, settings)
29
+ }
30
+
31
+ /// Loads an audio file from a type that implements Symphonia's [`MediaSource`]
32
+ /// trait.
33
+ #[ cfg_attr( docsrs, doc( cfg( feature = "symphonia" ) ) ) ]
34
+ pub fn from_media_source (
35
+ media_source : impl MediaSource + ' static ,
36
+ settings : StaticSoundSettings ,
37
+ ) -> Result < Self , FromFileError > {
38
+ Self :: from_boxed_media_source ( Box :: new ( media_source) , settings)
39
+ }
40
+
41
+ fn from_boxed_media_source (
13
42
media_source : Box < dyn MediaSource > ,
14
43
settings : StaticSoundSettings ,
15
44
) -> Result < Self , FromFileError > {
@@ -56,23 +85,4 @@ impl StaticSoundData {
56
85
settings,
57
86
} )
58
87
}
59
-
60
- /// Loads an audio file into a [`StaticSoundData`].
61
- #[ cfg( not( target_arch = "wasm32" ) ) ]
62
- #[ cfg_attr( docsrs, doc( cfg( all( feature = "symphonia" , not( wasm32) ) ) ) ) ]
63
- pub fn from_file (
64
- path : impl AsRef < std:: path:: Path > ,
65
- settings : StaticSoundSettings ,
66
- ) -> Result < Self , FromFileError > {
67
- Self :: from_media_source ( Box :: new ( std:: fs:: File :: open ( path) ?) , settings)
68
- }
69
-
70
- /// Loads a cursor wrapping audio file data into a [`StaticSoundData`].
71
- #[ cfg_attr( docsrs, doc( cfg( feature = "symphonia" ) ) ) ]
72
- pub fn from_cursor < T : AsRef < [ u8 ] > + Send + Sync + ' static > (
73
- cursor : Cursor < T > ,
74
- settings : StaticSoundSettings ,
75
- ) -> Result < StaticSoundData , FromFileError > {
76
- Self :: from_media_source ( Box :: new ( cursor) , settings)
77
- }
78
88
}
0 commit comments