PDA

View Full Version : How To Use Phonon?



ardisaz
28th November 2010, 18:03
Hai Guys, im new with Qt
I had a problem
I want to make a music player simulator (like piano or drum)
recently, i'm using QSound, but i have problem because i cant play multiple sound

I want to try using Phonon. But i found a problem...
My Code is

void uxbonang::bon_play(){
Phonon::MediaObject *music =
Phonon::CreatePlayer (Phonon::MusicCategory,
Phonon::MediaSource("C://Qt/Pro/sound.wav"));
}

i already included
phonon/MediaObject
phonon/MeidaSource

But i got an error message like this

"......undefined reference to '_imp__ZN6Phonon11MediaSourceC1ERK7QString'
...undefined reference to '_imp__ZN6Phonon12CreatePlayerENS_8CategoryERKNS_1 1MediaSourceE'
...undefined reference to '_imp_ZN6Phonon11MediaSourceD1Ev'
...undifned reference to '_imp_ZN6Phonon11MediaObjectPlayEv'
"

What should i Do?
thx

tbscope
28th November 2010, 18:20
Add

QT += phonon
to your .pro file

Then clean the project and rebuild.

ardisaz
28th November 2010, 18:57
thank you very much
now i can run my project
but i have warning like this " c:\NokiaQtSDK\Simulator\Qt\mingw\lib\QtCore.rl:1:U nescaped backslahsed are deprecated". its that oke?
and i when i touch play, the sound didn't play

again, thanks for your help :)

Added after 24 minutes:

Oh, it works...
Phonon cant read wav extension i guess, so i try to play mp3 and it worked well

one question, if everytime i touch the button play (like playing piano) with this code
void uxbonang::bon_play(){
Phonon::MediaObject *music =
Phonon::CreatePlayer (Phonon::MusicCategory,
Phonon::MediaSource("C://Qt/Pro/sound.wav"));
}

its meant that we create a lot of object music right? is that okey?
because i try to make variabel music outside the void and do the instantiation outside the void, when i try to play it, it only play the sound once. after that, the sound didn't play anymore...