c++audiomp3sdlsdl-mixer

How to Play Multiple MP3 files simultaneously in SDL?


I want to play multiple MP3 files in SDL. Using SDL_Mixer, I am able to play one MP3 file.

Mix_Music *music = Mix_LoadMUS("music.mp3");

Mix_PlayMusic(music, 0);

But when I am trying to play another MP3 along with first one, the first one stops and it plays the 2nd one. Can any one help on this?


Solution

  • SDL_mixer is meant to be a super-simple audio library; a single music track is one of its limitations.

    You could play the music as multiple sound effects. There are a few downsides though:

    Alternately, you can use a more advanced audio library that supports multiple music channels.