I want to play mp3 song file in ubuntu using c++
suggest me is their any function to do this
plz suggest me as simple as u can suggest any method....
plz give ur valueable suggestions.....

You could look into SDL (http://www.libsdl.org/). I know you can play audio files, not specifically sure about mp3s.

Also, please use real English words like "please" instead of "plz". It helps to keep DaniWeb looking professional!


I think for encoding and decoding, you can use libmp3lame from the LAME MP3 Project. I have never used it so I don't know how to use it, but I'm sure that the basic idea is to decode from mp3 to an uncompressed format and feed it through OpenAL (what SDL uses). I just saw that OpenAL now has an extension called AL_EXT_MP3 for playing mp3 files.

I have read the suggestions given by you but i need some simple functions through which i can play mp3 or audio files

Ok, well taken directly from the OpenAL Utility (ALUT) documentation. You can do the following:

#include <cstdlib>
#include <AL/alut.h>

int main (int argc, char **argv)
  ALuint sndBuffer, sndSource;
  alutInit (&argc, argv);
  sndBuffer = alutCreateBufferFromFile("my_sound_file.mp3");
  alGenSources (1, &sndSource); 
  alSourcei (sndSource, AL_BUFFER, sndBuffer);
  alSourcePlay (sndSource);
  alutSleep (1);
  alutExit ();
  return EXIT_SUCCESS;

And you are done. Just read the OpenAL documentation. It's all well explained in there.