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?
You can use QMediaPlayer for both files format .mp3 and .wav
#include <QtMultimedia/QMediaPlayer>
QMediaPlayer *player = new QMediaPlayer;
player->setMedia(QUrl::fromLocalFile("/path"));
player->setVolume(50);
player->play();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With