Problem: The following calls don't make QMediaPlayer play any sound.
player->setMedia(QUrl("qrc:/snd/coin-refund.mp3"));
player->play();
Where player
is of type QMediaPlayer*
.
Where the URL was generated using the QtCreator Copy URL option. So the file for sure is in the .qrc file.
Details:
I have a class derived from QObject
like this:
class MyClass : public QObject
{
Q_OBJECT
// some stuff
private:
QMediaPlayer* player;
}
A call to the QMediaPlayer standard constructor in the MyClass constructor like this...
MyClass::MyClass() :
player(new QMediaPlayer)
{
}
... causes the following error message on runtime (application compiles without any warnings)
QObject::startTimer: Timers can only be used with threads started with QThread
Removing the player removes this message (I haven't explicitly created any QThreads or QTimers).
In my .pro file I have :
QT += core gui webkitwidgets multimedia multimediawidgets widgets
Additional Information: I'm on Arch Linux, using QtCreator 4.2.2 and Qt 5.8.0
EDIT:
ldd your_executable
and show what you get. – eyllanesc