c++sdlsdl-mixer

Get currently playing Mix_Music with SDL_Mixer


I'm implementing sound in my C++ game with SDL_Mixer, and can't find a function in the manual that would give me the Mix_Music that is currently playing. I figure I need it to know whether I can free the Mix_Music or not, depending on whether it is currently playing.


Solution

  • According to https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC56 you can simply free the music whether it is playing or not. The music will halt if it is playing, or finish fading out if it is fading out.

    You had better just remember the last music you asked to be played yourself if you want to keep track of it for other reasons.