X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDL-Mixer-Music.html-inc;h=5f97a0eb8acd4696a53852c2bf37622098d22836;hb=09d3d3cea1d78106a6284e2a928d737875936240;hp=12c72a6a89dbb8b949731fab25b129dbce329225;hpb=2d13cef7f6c61e09ecbc7f2e4b0cfd66c2078020;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDL-Mixer-Music.html-inc b/pages/SDL-Mixer-Music.html-inc index 12c72a6..5f97a0e 100644 --- a/pages/SDL-Mixer-Music.html-inc +++ b/pages/SDL-Mixer-Music.html-inc @@ -47,17 +47,13 @@
 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.

hook_music

 SDL::Mixer::Music::hook_music( $callback, $position );
 
- or
-
- 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. @@ -66,10 +62,10 @@ The music player will then be called automatically when the mixer needs it. Musi 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: 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:

-
 my $callback = sub
+
 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
@@ -83,9 +79,9 @@ Using a custom music player and the internal music player is not possible, the c
      }
 
      return @stream;
- };
+ }
 
- SDL::Mixer::Music::hook_music( $callback, 0 );
+ SDL::Mixer::Music::hook_music( 'main::callback', 0 );
 
 
@@ -95,14 +91,18 @@ Using a custom music player and the internal music player is not possible, the c
 SDL::Mixer::Music::hook_music_finished( $callback );
 
 
-

This callback is called when music called by e.g. play_music or fade_in_music stops naturally. This happens when the music is over or is -fading out.

-

Note: If you play music via hook_music, this callback will never be called.

+

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);
- my $callback         = sub{ $music_is_playing = 0; };
- SDL::Mixer::Music::hook_music_finished( $callback );
+ sub callback
+ {
+     $music_is_playing = 0;
+ }
+
+ SDL::Mixer::Music::hook_music_finished( 'main::callback' );
 
  foreach my $this_song ( @music )
  {
@@ -122,7 +122,7 @@ fading out.

 my $position = SDL::Mixer::Music::get_music_hook_data();
 
 
-

Returns the position (first) parameter that will be passed to hook_music's callback.

+

Returns the position (first) parameter that will be passed to SDL::Mixer::Music::hook_music's callback.

play_music

@@ -148,7 +148,7 @@ Passing -1 to $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.

fade_out_music

@@ -242,7 +242,7 @@ Passing zero is similar to rewinding the song.

MP3

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.