pub struct Music<'a> {
pub raw: *mut Mix_Music,
pub owned: bool,
/* private fields */
}Expand description
This is an opaque data type used for Music data.
Fields§
§raw: *mut Mix_Music§owned: boolImplementations§
Source§impl<'a> Music<'a>
impl<'a> Music<'a>
Sourcepub fn from_file<P: AsRef<Path>>(path: P) -> Result<Music<'static>, String>
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Music<'static>, String>
Load music file to use.
Sourcepub fn from_static_bytes(buf: &'static [u8]) -> Result<Music<'static>, String>
pub fn from_static_bytes(buf: &'static [u8]) -> Result<Music<'static>, String>
Load music from a static byte buffer.
Sourcepub fn play(&self, loops: i32) -> Result<(), String>
pub fn play(&self, loops: i32) -> Result<(), String>
Play the loaded music loop times through from start to finish. Pass -1 to loop forever.
Sourcepub fn fade_in(&self, loops: i32, ms: i32) -> Result<(), String>
pub fn fade_in(&self, loops: i32, ms: i32) -> Result<(), String>
Fade in over ms milliseconds of time, the loaded music, playing it loop times through from start to finish.
Sourcepub fn fade_in_from_pos(
&self,
loops: i32,
ms: i32,
position: f64,
) -> Result<(), String>
pub fn fade_in_from_pos( &self, loops: i32, ms: i32, position: f64, ) -> Result<(), String>
Fade in over ms milliseconds of time, from position.
Sourcepub fn get_volume() -> i32
pub fn get_volume() -> i32
Returns current volume
Sourcepub fn set_volume(volume: i32)
pub fn set_volume(volume: i32)
Set the volume on a scale of 0 to 128. Values greater than 128 will use 128.
Sourcepub fn set_pos(position: f64) -> Result<(), String>
pub fn set_pos(position: f64) -> Result<(), String>
Set the position of the currently playing music.
Sourcepub fn set_command(command: &str) -> Result<(), String>
pub fn set_command(command: &str) -> Result<(), String>
Setup a command line music player to use to play music.
Sourcepub fn fade_out(ms: i32) -> Result<(), String>
pub fn fade_out(ms: i32) -> Result<(), String>
Gradually fade out the music over ms milliseconds starting from now.
Sourcepub fn hook_finished(f: fn())
pub fn hook_finished(f: fn())
Sets up a function to be called when music playback is halted.
§Examples
fn after_music() {
println!("Music has ended");
}
sdl2::mixer::Music::hook_finished(after_music);Sourcepub fn unhook_finished()
pub fn unhook_finished()
A previously set up function would no longer be called when music playback is halted.
Sourcepub fn is_playing() -> bool
pub fn is_playing() -> bool
If music is actively playing, or not.
Sourcepub fn get_fading() -> Fading
pub fn get_fading() -> Fading
If music is fading, or not.