I found a work around but I still don't understand why the loop parameter doesn't work for Mix_PlayMusic(Music, loops)...
My Solution
Code:
procedure LoadPlayMusic;
begin
if Mix_OpenAudio(44100, AUDIO_S16LSB, 2, 4096) = -1 then
begin
SDL_Quit;
halt;
end;
Music := Mix_LoadMUS('CrazyChe.ogg');
if Music = nil then
begin
SDL_Quit;
halt;
end;
if Mix_PlayMusic(Music, 0) = -1 then
begin
SDL_Quit;
halt;
end;
end;
procedure MusicFinished;
begin
Mix_HaltMusic;
Mix_FreeMusic(Music);
LoadPlayMusic;
end;
begin
if SDL_Init( SDL_INIT_AUDIO or SDL_INIT_VIDEO ) <> 0 then
halt;
// Set the title bar in environments that support it
SDL_WM_SetCaption( 'Sprite Engine : Shooting', nil );
LoadPlayMusic;
Mix_HookMusicFinished(@MusicFinished);
begin
When the Mixer, detects the end of playing the music file, it will call the musicFinished Method,
which calls the LoadPlayMusic Method once it frees the previous Music Pointer.
This will do for now, but would like some help with Mix_PlayMusic, so it will loop by itself...
CheGueVerra
Bookmarks