Struct Music
pub struct Music<'a> {
pub raw: *mut _Mix_Music,
pub owned: bool,
/* private fields */
}
dep_sdl2
only.Expand description
This is an opaque data type used for Music data.
Fields§
§raw: *mut _Mix_Music
§owned: bool
Implementations§
§impl<'a> Music<'a>
impl<'a> Music<'a>
pub 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.
pub 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.
pub 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.
pub 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.
pub fn get_volume() -> i32
pub fn get_volume() -> i32
Returns current volume
pub 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.
pub fn pause()
pub fn pause()
Pause the music playback.
pub fn resume()
pub fn resume()
Unpause the music.
pub fn rewind()
pub fn rewind()
Rewind the music to the start.
pub fn set_pos(position: f64) -> Result<(), String> ⓘ
pub fn set_pos(position: f64) -> Result<(), String> ⓘ
Set the position of the currently playing music.
pub 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.
pub fn halt()
pub fn halt()
Halt playback of music.
pub 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.
pub 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);
pub fn unhook_finished()
pub fn unhook_finished()
A previously set up function would no longer be called when music playback is halted.
pub fn is_playing() -> bool
pub fn is_playing() -> bool
If music is actively playing, or not.
pub 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> Freeze for Music<'a>
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Source§impl<T> ExtAny for T
impl<T> ExtAny for T
Source§fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId
of Self
using a custom hasher.Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§impl<T> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Source§fn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Source§fn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Source§fn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Hook for T
impl<T> Hook for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more