Expand description
This is an opaque data type used for Music data.
Fields
raw: *mut Mix_Musicowned: boolImplementations
sourceimpl<'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.
Trait Implementations
impl<'a> StructuralPartialEq for Music<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for Music<'a>
impl<'a> !Send for Music<'a>
impl<'a> !Sync for Music<'a>
impl<'a> Unpin for Music<'a>
impl<'a> UnwindSafe for Music<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more