QMediaplayer Sound file problem
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:
Code:
QMediaPlayer * ErrorSound;
At cpp, in the constructer, I load the sounds:
Code:
ErrorSound = new QMediaPlayer();
ErrorSound
->setMedia
(QUrl("qrc:/Error.wav"));
Further in the correct place I call it to play:
Code:
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.
Re: QMediaplayer Sound file problem
In the header define the following
Code:
private:
QPointer <QMediaPlayer> mp3backgroundplayer;
signals:
void playmp3background();
void stopmp3background();
in the code use this to load it from the resource file
Code:
QPointer <QMediaPlayer> mp3backgroundplayer
= new QMediaPlayer
(this);
// ...
mp3backgroundplayer
->setMedia
(QUrl("qrc:/spacegame/images/gamemedia/spacegamebackground.mp3"));
mp3backgroundplayer->setVolume(30);
mp3backgroundplayer->l
mp3backgroundplayer->play();
connect(this,SIGNAL(playmp3background()),mp3backgroundplayer.data(),SLOT(play()));
connect(this, SIGNAL(stopmp3background()), mp3backgroundplayer.data(), SLOT(stop()));
to stop use this
Code:
this.emit(stopmp3background());
good luck