/* call-seq:
* play( repeats = 0 ) -> self
*
* Play music, repeating a certain number of extra times. If
* any music was already playing, that music will be stopped
* first, and this music will start.
*
* Raises SDLError if something goes wrong.
*
* This method takes these arguments:
* repeats:: how many extra times to play the music.
* Can be -1 to repeat forever until it is stopped.
*/
VALUE rbgm_mixmusic_play(int argc, VALUE *argv, VALUE self)
{
Mix_Music* music;
int reps, result;
VALUE repsv;
Data_Get_Struct( self, Mix_Music, music );
rb_scan_args(argc, argv, "01", &repsv);
if( RTEST(repsv) )
{
reps = NUM2INT(repsv);
}
else
{
reps = 0;
}
if( reps > -1 )
{
/* Adjust so repeats means the same as it does for Samples */
reps += 1;
}
result = Mix_PlayMusic(music, reps);
if ( result < 0 )
{
rb_raise(eSDLError, "Error playing music: %s",
Mix_GetError());
}
return self;
}