Playing MP3 File

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tdbvnr
    New Member
    • Sep 2006
    • 2

    Playing MP3 File

    Hi..
    Anybody know how to play a MP3 file in C. Is there any header files available for it ? Is it a complex task. What should i know in order to play a MP3 file ? Suggest me please....
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    It is a very complex task, you will either need to know most of the MPEG2 specification or find a libarray that does the decode for you.

    Comment

    • rawinder dhillon
      New Member
      • Oct 2006
      • 8

      #3
      i dont think it is possible

      Comment

      • SILVERADO
        New Member
        • Feb 2008
        • 2

        #4
        Originally posted by rawinder dhillon
        i dont think it is possible
        Of course its possible Windows was written in C++.

        Comment

        • SILVERADO
          New Member
          • Feb 2008
          • 2

          #5
          Originally posted by tdbvnr
          Hi..
          Anybody know how to play a MP3 file in C. Is there any header files available for it ? Is it a complex task. What should i know in order to play a MP3 file ? Suggest me please....
          The easiest way to go about doing that is to convert the mp3 file to a wav file to avoid having to import the AudioX library to your program which may require additional work. Here is the code I came up with that worked on a video game i developed.

          #include <windows.h>
          #include <mmsystem.h>
          #pragma comment(lib, "winmm.lib" )

          char* declaredVariabl e = "C:\\nameOfSong .wav";

          /*where declaredVariabl e can be name of song or whatever and C:\\ should lead to the directory where your audio file has been stored*/

          int main()
          {

          sndPlaySound(de claredVariable, SND_ASYNC);

          return 0;
          }


          It doesnt get much easier than this.

          Comment

          Working...