PDA

View Full Version : QMediaPlayer Sound not working in other PCs



digimonkey
13th March 2015, 04:29
Hello,

I have a problem with QMediaPlayer play sound in a different PC than in the developed one.
The release program works just fine in the PC that I have developed (I've copied all *.dll,...), but trying to use the same program in a different PC there is no sound.
I have my sounds in my Resources and their are together with the images that I use, so it isn't path fail.

I create in the header (*.h) file my QMediaPlayer variable:

QMediaPlayer * ErrorSound;


At cpp, in the constructer, I load the sounds:

ErrorSound = new QMediaPlayer();
ErrorSound->setMedia(QUrl("qrc:/Error.wav"));

Further in the correct place I call it to play:

ErrorSound->play();


I've checked the Data.qrc (my resource file) and all files are there:
<RCC>
<qresource prefix="/">
.......other files
<file>Error.wav</file>
</qresource>
</RCC>

All image files and sound files are in same place, same folder, as the *.exe file.

If anyone got this problem and know how to fix it i would thank you for helping me out.

## UPDATE ##

I've tried a new thing, that is load the current path and load directly the sound, instead using it as resource.


mFilename = mDir.absolutePath();
ErrorSound->setMedia(QUrl(mFilename + QLatin1Char('/') + "Error.wav"));
ErrorSound->play();

The sound stills work in the compiled PC and not in others. What's the secret?

jefftee
13th March 2015, 04:36
Have you distributed the necessary plugins with your application and are they installed where Qt looks for them?

http://qt-project.org/doc/qt-4.8/deployment-plugins.html or
https://doc-snapshots.qt.io/qt5-5.4/windows-deployment.html#qt-plugins

depending on your Qt version.

Edit: I don't develop on Windows, but the windeployqt tool looks like it might help ensure you have packaged all of the required plugins with your application. I develop on Mac and the macdeployqt tool is invaluable.

Hope that helps.

digimonkey
13th March 2015, 05:07
Thank you!

Windeployqt is just great, didnt knew about it.

All working now :)