tags:

views:

180

answers:

1

Hi I tried to play a audio file in Qt 4.4 in windows XP using phonon classes (MediaObject,MediaSource,AudioOutput). The code gets compiled and ran but the audio file is not playing. I enabled the phonon support and setup the backend as well. Someone can please help me with this. i attached my code also for reference. Also i dont want to use QDesktopServices and all.

Phonon::AudioOutput *audioOutput=new Phonon::AudioOutput(Phonon::MusicCategory,this);
Phonon::MediaObject *mediaObject=new Phonon::MediaObject(this);
mediaObject->setTickInterval(1000);
Phonon::createPath(mediaObject,audioOutput);
Phonon::MediaSource source("D:\\CAT\\audioFile.mp3");
mediaObject->setCurrentSource(source);
mediaObject->play();
A: 

your code seem to be fine; what you might want to check if your backend (I guess DirectShow if you're running windows) has needed audio device available or/and the audio format is supported by backend. In order to do this you can use functions from Phonon BackendCapabilities namespace. As an alternative you can build and run an example application which comes with QT, it should be in your_qt_folder/examples/phonon/capabilities

alt text

more details regarding this example here: Capabilities Example

I guess if it doesn't show you anything then you need to check your backend installation or your audio device or\and format are not supported

serge_gubenko