Nintendo 3DS >> C/C++ >> SDL v1.2

Hook Music Finished


參考資訊:
1. libctru doc
2. 3ds-examples

說明:

API
void Mix_HookMusicFinished(void (SDLCALL *music_finished)(void))

main.c

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <SDL.h>
#include <SDL_mixer.h>
 
static int complete = 0;
 
static void music_play_complete(void)
{
    complete = 1;
}
 
int main(void)
{
    SDL_Init(SDL_INIT_AUDIO);
    Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096);

    Mix_Music *music = Mix_LoadMUS("main.wav");
    Mix_HookMusicFinished(music_play_complete);
    Mix_PlayMusic(music, 1);

    while (complete == 0) {
        usleep(100000);
    }

    Mix_HaltMusic();
    Mix_FreeMusic(music);
    Mix_CloseAudio();
    SDL_Quit();
    return 0;
}


返回上一頁