Phonon audible output fail
This is my code:
media_object_ = new Phonon::MediaObject(this);
fileName="./DemoEN2.wav";
media_object_->setCurrentSource(fileName);
media_object_->play();
I have the includes:
#include <Phonon/MediaObject>
#include <Phonon/MediaSource>
#include <phonon>
And:
Phonon::MediaObject *media_object_;
QString fileName;
When I run the .exe (/bin/folder) I can not listen the DemoEN2.wav (That is in the same /bin/ folder). There is no output.
My sou开发者_运维问答nd system works, and I can not see any apparent problem. Do you have any idea?
You need to connect the media source to media output:
Phonon::MediaObject *media_object_;
Phonon::AudioOutput *audio_output_;
...
media_object_ = new Phonon::MediaObject(this);
fileName="./DemoEN2.wav";
media_object_->setCurrentSource(fileName);
audio_output_ = new Phonon::AudioOutput(Phonon::MusicCategory, this);
Phonon::createPath(media_object_, audio_output_);
media_object_->play();
精彩评论