Struct rich_sdl2_rust::mixer::music::MixMusic
source · pub struct MixMusic<'device> { /* private fields */ }Expand description
A music buffer of the audio data.
Implementations§
source§impl<'device> MixMusic<'device>
impl<'device> MixMusic<'device>
sourcepub fn music_type(&self) -> MusicType
pub fn music_type(&self) -> MusicType
Returns the type of the music.
sourcepub fn with_cmd(
device: &'device MixDevice<'device>,
file_name: &str,
command: &str
) -> Result<Self>
pub fn with_cmd( device: &'device MixDevice<'device>, file_name: &str, command: &str ) -> Result<Self>
Constructs a music from the file with the custom player command, or Err on failure.
The command must handle the signals emitted by the SDL2_mixer:
- On stop:
SIGTERMsignal - On pause:
SIGSTOPsignal - On unpause:
SIGCONTsignal
§Panics
Panics if file_name or command is empty.
sourcepub fn play(&self, loops: Option<u32>) -> Result<()>
pub fn play(&self, loops: Option<u32>) -> Result<()>
Plays the music. If a music is already playing, it synchronously waits until the music ends.
If loops is None, the play continues infinitely.
sourcepub fn fade_in(
&self,
fade_in: u32,
loops: Option<u32>,
begin: Option<f64>
) -> Result<()>
pub fn fade_in( &self, fade_in: u32, loops: Option<u32>, begin: Option<f64> ) -> Result<()>
Plays the music with fade-in times in milliseconds and begin times in seconds. If a music is already playing, it synchronously waits until the music ends.
If loops is None, the play continues infinitely.
If begin is None, the play begins from the start.
sourcepub fn set_pos(&self, pos: f64) -> Result<()>
pub fn set_pos(&self, pos: f64) -> Result<()>
Sets the music position in seconds, or Err on failure.
sourcepub fn set_volume(&self, volume: u32)
pub fn set_volume(&self, volume: u32)
Sets the volume of the music. The volume is clamped in 0..=128.
sourcepub fn rewind(&self)
pub fn rewind(&self)
Rewinds the music to the beginning. Rewinding is valid only mod, ogg vorbis, mpeg-1 layer-3, and midi format.
sourcepub fn fade_out(&self, fade_out: u32) -> Result<()>
pub fn fade_out(&self, fade_out: u32) -> Result<()>
Halts the music with fade-out in milliseconds.
sourcepub fn is_playing(&self) -> bool
pub fn is_playing(&self) -> bool
Returns whether the music is playing.
sourcepub fn fading_state(&self) -> FadingState
pub fn fading_state(&self) -> FadingState
Returns the fading state of the music.