I want to run .mp3 file using phonon namespace
Hi, i am learning Qt, i want to run .mp3 file, so that i write a basic code, but it is giving error,can you check it
int main(int argv, char **args)
QApplication app(argv, args);
// The below portion of code is to run .mp3 file Phonon::MediaObject *mediaobject = new Phonon::MediaObject; QString filename("C:\Users\Public\Music\Sample Music"); mediaobject->setCurrentSource(filename); Phonon::AudioOutput *audio = new Phonon::AudioOutput; Phonon::createPath(mediaobject,audio); mediaobject->play(); //.............................................................. return app.exec();
Edit: please use @ tags around your code sections; Andre
If you have a problem, please be specific on what problem you have. In this case, don't just say "is giving error", but tell us about the specific error. In this case, we also need information on your platform (windows? linunx? mac? some other platform? what version?) and your Qt version.
One thing that is immediately obvious from your code though, is that the path you give is not going to work (line 18). Backslashes need to be escaped in strings. However, in Qt, you can just use forward slashes instead.
i am using windows platform, and Qt SDK 1.1.4.
i have tried with forwrd slash and these error came.
error 1:- C:\MeeGoSDK_1.2\Himanshu\Test\Music-build-desktop-Desktop-MinGW_Debug..\Music\main.cpp:17: error: undefined reference to `_imp___ZN6Phonon11MediaObjectC1EP7QObject'
error 2:- C:\MeeGoSDK_1.2\Himanshu\Test\Music-build-desktop-Desktop-MinGW_Debug..\Music\main.cpp:19: error: undefined reference to `_imp___ZN6Phonon11MediaSourceC1ERK7QString'
errror 3:- C:\MeeGoSDK_1.2\Himanshu\Test\Music-build-desktop-Desktop-MinGW_Debug..\Music\main.cpp:19: error: undefined reference to `_imp___ZN6Phonon11MediaSourceD1Ev'
error 4:- C:\MeeGoSDK_1.2\Himanshu\Test\Music-build-desktop-Desktop-MinGW_Debug..\Music\main.cpp:19: error: undefined reference to `_imp___ZN6Phonon11MediaSourceD1Ev'
is this api is also needed or not "mediaobject = Phonon::createPlayer(Phonon::MusicCategory,Phonon::MediaSource("C:/Users/Public/Music/Sample Music"));"
Are you actually linking to the phonon libs?
thanks for reply, yes i was not linking phonon library in my .pro file, when i use this syntax QT +=phonon in my .pro file it starts working