I'm trying to play an mp3 file as background music for my game but somehow the music cannot start and I get this error "Unrecognized audio format". As far as i know, the SDL_mixer 2.6.3 does support mp3 file and I'm sure that the file path is correct. Here is my code:
`if(Mix_Init(1)==0)
{
cout << "Sound can not initilize!" << Mix_GetError() << endl;
}
else
{
backgroundSound = Mix_LoadMUS("sound/bgmusic.mp3");
if(backgroundSound == NULL)
cout << "failed" << Mix_GetError();
}your text`
I want an explanation for the error and how to fix it
You need to pass required audio formats to
Mix_Initand check if it succeded (in your case - MIX_INIT_MP3), e.g.You can only load sound files after you open sound device, e.g.: