QSound only works on my development machine
-
wrote on 11 Apr 2016, 16:09 last edited by
I can get QSound to play on my development kit (Qt5.4, Windows7, VS2013+QtPlugin) using this code:
SoundFx::SoundFx(QObject *parent) : QObject(parent)
{
sound_dir = QString::fromStdString(FedTerm::base_dir) + "/sounds/";
}void SoundFx::Play(int sound)
{
switch(sound)
{
case ALERT: QSound::play(QDir::toNativeSeparators(sound_dir + "alert.wav")); break;
case FRIENDS: QSound::play(QDir::toNativeSeparators(sound_dir + "friends.wav")); break;
}
}However, on other computers, for some reason I can't fathom, it just doesn't play. The directory is correct, and there is no error message. I the multimedia library is present. I'm sure I'm missing something obvious, but I have no idea what.
Can anyone point me in the right direction?
Many thanks,
Alan
-
Lifetime Qt Championwrote on 11 Apr 2016, 16:13 last edited by mrjj 4 Nov 2016, 16:14
@alan.lenton said:
Hi
Are you 100% sure that
FedTerm::base_dir
is pointing to the correct folder on the "other" machines?Also if u run the .exe in the deploy folder on your own machine,
does it just work? -
wrote on 11 Apr 2016, 17:21 last edited by
On windows you have to deploy the audio plugin qtaudio_windows.dll and qtmedia_audioengine.dll
-
On windows you have to deploy the audio plugin qtaudio_windows.dll and qtmedia_audioengine.dll
wrote on 2 May 2016, 13:44 last edited byThank you that worked - once I'd figured out the directories to put them in!
There's nothing in the documentation for QSound that indicates you need plugins. It would be nice if those bits of the library that need plugins told you which ones it needs. For instance:
Header: #include <QSound>
qmake: QT += multimedia
Plugins: qtaudio_windows.dll, qmedia_audioengine.dllBy the way, I happen to think that in general,the Qt documentation is very good :)
alan
-
Hi,
That's what usually windeployqt does for you :)