Greetings!
I’m experimenting with developing android apps in SDL 2.0, and everything seems to be fine, except that I can’t make any sound effects, or music.
I tried using Mix_Chunk *chunk and Mix_Music *music as well, using the Mix_LoadWAV() or the Mix_LoadMUS() function, but all it gives back is a NULL pointer, and I can’t figure out why.
I tried putting the wav file into the assets directory, and in the jni/src directory but none of them worked, where do I have to place it?
Here’s my code:
Code:
int main(int argc, char *argv[])
{
int w,h, num=0;
SDL_Event event;
Mix_Chunk *chunkey=NULL;
SDL_CreateWindowAndRenderer(0, 0, 0, &window, &renderer);
SDL_GetWindowSize(window,&w,&h);
SDL_Init(SDL_INIT_AUDIO);
Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 2048 );
chunkey=Mix_LoadWAV("Test.wav"); //it is in the assets directory right now, but didn't work even if it was in the root dir
if (chunkey==NULL)
exit(0);
while(num<3)
{
while (SDL_PollEvent(&event))
{
if (event.type==SDL_FINGERDOWN)
{
Mix_PlayChannel(-1, chunkey, 5); //tried with various arguments
num++;
}
}
}
exit(0);
return 0;
}
Thank you in advance!