X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDL-Mixer-Music.html-inc;h=4fa2a7215c55b21679b709d6b149cb12adaf5e63;hb=d5943b684b1240307fbf0a103abbf18dd93998f4;hp=7d3f9a9ad00f4c7804fc3b28124166b5971a66ad;hpb=e37eb25838e54a5c3d082940c0d1d97f5afcdbd6;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDL-Mixer-Music.html-inc b/pages/SDL-Mixer-Music.html-inc index 7d3f9a9..4fa2a72 100644 --- a/pages/SDL-Mixer-Music.html-inc +++ b/pages/SDL-Mixer-Music.html-inc @@ -4,13 +4,8 @@
SDL::Mixer::Music -- SDL_Mixer music functions and bindings
+SDL::Mixer::Music - functions for music
Mixer
-Same as SDL::Audio::mix()
- -has to be implemented
- -my $music = SDL::Mixer::Music::load_MUS( $file );-
load_MUS
loads a music file into a SDL::Music::MixMusic
structure. This can be passed to play_music.
load_MUS
loads a music file into a SDL::Mixer::MixMusic
structure. This can be passed to SDL::Mixer::Music::play_music.
SDL::Mixer::Music::hook_music( $callback, $position ); + ++
This sets up a custom music player function, so you can pass your own audio stream data into the SDL::Mixer.
+The function will be called with position
passed into the first parameter when the callback
is called.
+The audio stream buffer has to be filled with length bytes of music (2nd parameter).
+The music player will then be called automatically when the mixer needs it. Music playing will start as soon as this is called.
+All the music playing and stopping functions have no effect on music after this. Pause and resume will work.
+Using a custom music player and the internal music player is not possible, the custom music player takes priority.
To stop the custom music player call hook_music()
without arguments.
Note: NEVER call SDL::Mixer
functions, nor SDL::Audio::lock, from a callback function.
Note: At program termination also call SDL::Mixer::Music::hook_music()
to stop this callback.
Example:
+sub callback + { + my $position = shift; # position (first time its 0, on each call $length is added) + my $length = shift; # length of bytes we have to put in stream + my @stream = ''; + + printf("position=%8d, stream length=%6d\n", $position, $length); + + for(my $i = 0; $i < $length; $i++) + { + push(@stream, (($i + $position) & 0xFF)); + } + + return @stream; + } + + SDL::Mixer::Music::hook_music( 'main::callback', 0 ); + +
SDL::Mixer::Music::hook_music_finished( 'main::callback' ); + ++
This callback is called when music called by e.g. SDL::Mixer::Music::play_music or SDL::Mixer::Music::fade_in_music stops naturally. +This happens when the music is over or is fading out.
+Note: If you play music via SDL::Mixer::Music::hook_music, this callback will never be called.
+Example:
+my $music_is_playing = 0; + my @music = qw(first.mp3 next.mp3 other.mp3 last.mp3); + sub callback + { + $music_is_playing = 0; + } + + SDL::Mixer::Music::hook_music_finished( 'main::callback' ); + + foreach my $this_song ( @music ) + { + SDL::Mixer::Music::play_music( $this_song, 0 ); + $music_is_playing = 1; + + SDL::delay( 100 ) while( $music_is_playing ); + } + + SDL::Mixer::Music::hook_music_finished(); # cleanup + +
my $position = SDL::Mixer::Music::get_music_hook_data(); + ++
Returns the position
(first) parameter that will be passed to SDL::Mixer::Music::hook_music's callback.
$loops
will loop the music infinitely.
my $music = SDL::Mixer::Music::fade_in_music( $mix_music, $loops, $ms );-
Same as play_music but you can specify the fade-in time by $ms
.
Same as SDL::Mixer::Music::play_music but you can specify the fade-in time by $ms
.
$loops
will loop the music infinitely.
my $volume_before = SDL::Mixer::Music::volume_music( $new_volume ); + ++
volume_music
set the volume in $new_volume
and returns the volume that was set before.
+Passing -1
as argument causes only to return the current volume.
Volume is between 0
(silence) and MIX_MAX_VOLUME = 128
.
Example:
+# set the music volume to 1/2 maximum, and then check it + printf( "volume was : %d\n", SDL::Mixer::Music::volume_music( MIX_MAX_VOLUME / 2 ) ); + printf( "volume is now : %d\n", SDL::Mixer::Music::volume_music( -1 ) ); + +
Jumps to position seconds from the current position in the stream. -So you may want to call rewind_music before this. +So you may want to call SDL::Mixer::Music::rewind_music before this. Does not go in reverse... negative values do nothing.
-Returns: 0
on success, or -1
if the codec doesn't support this function.
Returns: 0
on success, or -1
if the codec doesn't support this function.
my $paused = SDL::Mixer::Music::paused_music();-
Returns 1
if the music is paused, otherwise 0
.
Returns 1
if the music is paused, otherwise 0
.
my $playing_music = SDL::Mixer::Music::playing_music();-
Returns 1
if the music is playing sound, otherwise 0
. It does'nt check if the music is paused.
Returns 1
if the music is playing sound, otherwise 0
. It does'nt check if the music is paused.
See AUTHORS in SDL.