PDA

View Full Version : problem with phonon



franco.amato
15th March 2011, 18:41
Hi to all,
I have some problem using the Phonon module. I would use it to play an audio file.
This is the code I used.
In my *.h file:

Phonon::AudioOutput *audioOutput;
Phonon::MediaObject *mediaObject;
Then in my *.cpp file:

audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
mediaObject = new Phonon::MediaObject(this);
Phonon::Path path = Phonon::createPath(mediaObject, audioOutput);

mediaObject->setCurrentSource(Phonon::MediaSource(":/sounds/file.wav"));
mediaObject->play();
When I execute the code I don't listen nothing. Instead if I try to play the file with the phonon demo there is no problem.
Which can be the problem?

Regards

franco.amato
17th March 2011, 13:44
I hope to get a reply,
22 Views and no reply.
Best Regards

KShots
17th March 2011, 19:25
Using qt resources can be tricky. Some classes require you to access resources by pre-pending a colon (':'), others by prepending a "qrc:". Try prepending accessing your resource via this: "qrc:/sounds/file.wav".

Also, make certain that your resource is actually being built into your executable.

franco.amato
17th March 2011, 21:53
Using qt resources can be tricky. Some classes require you to access resources by pre-pending a colon (':'), others by prepending a "qrc:". Try prepending accessing your resource via this: "qrc:/sounds/file.wav".

Also, make certain that your resource is actually being built into your executable.

Hi I solved the problem using the fullpath instead of resources.
Thank you