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

Load Music from Memory


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

說明:

API
Mix_Music* Mix_LoadMUS_RW(SDL_RWops *src, int freesrc)

main.c

#include <stdio.h>
#include <stdlib.h>
#include <SDL.h>
#include <SDL_mixer.h>
 
#include "hex_wav.h"
  
int main(void)
{
    SDL_Init(SDL_INIT_AUDIO);
    Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096);

    SDL_RWops *rw = SDL_RWFromMem(hex_wav, sizeof(hex_wav));
    Mix_Music *music = Mix_LoadMUS_RW(rw);
    Mix_PlayMusic(music, 1);
    SDL_Delay(3000);

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


返回上一頁