Cant play music with SDL_mixer

Hello. I have been trying to play music, but unfortuantly, I have not been able to play the music. I do not know why, as no error shows up, but the music is not playing.

Code :

Mix_Init(0);
Mix_Music* music = Mix_LoadMUS(“original-tetris-theme-tetris-soundtrack.mp3”);
if (Mix_PlayingMusic() == 0) {
Mix_PlayMusic(music, 1);
}

//Code is under one function that repeats in a while loop, along with all the rendering.

Hello again. I have figured out my issue, and for anyone else who has this issue, first, instead of putting Mix_Init(0), you need to put what you want to initialize. Because I am playing an mp3 sound, you will need to put Mix_Init(MIX_INIT_MP3). Before initializing the mp3, you will also have to use Mix_OpenAudio, and you will also have to increase the volume using Mix_VolumeMusic.

Code :
void Game::render() {

int flags = MIX_INIT_MP3;
Mix_OpenAudio(22050, AUDIO_S16SYS, 2, 640);
Mix_Init(flags);
Mix_Music* music = Mix_LoadMUS("song.mp3");
Mix_VolumeMusic(120);
if (Mix_PlayingMusic() == 0) {
	Mix_PlayMusic(music, 1);
}

. . . . . .
}

2 Likes