2
votes

Why would SDL_Mixer not play music for certain mp3s?

I am utilizing SDL_Mixer for music playback in an application I am creating. On certain songs (entire albums actually), the music will simply not play without returning any errors. The music data loads successfully using Mix_LoadMUS and when executing Mix_PlayMusic with that data, it oddly enough returns 0 for success but plays no music. I have also tried reading Mix_GetError() and SDL_GetError() (I believe they're the same) to see if it raises an error, but no such luck.

My question is, what other reasons would SDL_mixer not be able to play a particular mp3?

I know the mp3's are functional since I can play them in other music players. I also know for a fact that they are not playing (as opposed to perhaps the volume being turned down) since Mix_PlayingMusic returns 0.

Thanks everyone!

3

3 Answers

1
votes

This actually wound up being a sound issue with that particular computer. Upon trying the same tests on another machine, the sound worked flawlessly. Just a quick note in case someone else encounters this issue.

0
votes

Different implementations of the MP3 algorithm tolerate different levels of conformance to the format. Most of the music players are pretty tolerant, because most users would rather hear something choppy than nothing at all, but the playback libraries that are common tolerate much less.

I'd recommend opening the offending (Or all) mp3's in an audio sample editor, such as Audacity, and reexporting the mp3. You might lose just a little bit of quality since the mp3 compression is by it's nature lossy, but it's likely to fix the playback problem.

0
votes

I had the same problem, and reexporting the mp3-files with audacity did not help, but by doing something like this: if (Mix_PlayingMusic() == 0) Mix_PlayMusic() in the event loop, the music played after 2 or 3 attempts (that was different every time I ran the program). Another solution was to convert the music to .ogg files.