How to play MP3 files in C?

Using FMOD (cross platform), this should be as simple as this:

#include <conio.h>
#include "inc/fmod.h"


int main ()
   // init FMOD sound system
   FSOUND_Init (44100, 32, 0);

   // load and play mp3
   handle=FSOUND_Sample_Load (0,"my.mp3",0, 0, 0);
   FSOUND_PlaySound (0,handle);

   // wait until the users hits a key to end the app
   while (!_kbhit())

   // clean up
   FSOUND_Sample_Free (handle);

As a side note, I’d suggest you using C++ over C.

Leave a Comment