How can I play sound with Qt? I tried this:
QSound::play("sounds/croack.wav");
QSound doesn't work on my ubuntu (seems that it requires NAS, although after I installed it it still doesn't work). Is there a simple one line Qt-only solution or do I need to throw in SDL or something else?
Ok I have some progress, I can play ogg files but not wav (dunno why).
#include <QtGui>
#include <phonon/phonon>
int main(int argc, char* argv[]) {
QApplication app( argc, argv );
app.setApplicationName("bla");
Phonon::MediaObject *mediaObject = Phonon::createPlayer(Phonon::NoCategory, Phonon::MediaSource("sounds/4.wav"));
mediaObject->play();
return app.exec();
}
Compiled with g++ ``pkg-config QtGui phonon --cflags --libs``
.