QSoundEffect not working in Qt 6.4.2 windows 10
-
Hi Guys i would like to play a soundeffect with the QSoundEffect but when i tried in this way:
QSoundEffect *soundEffect = new QSoundEffect(); soundEffect->setSource(QUrl("D:/QtProjectver200/Android_alarm/RES/alligator3.wav")); soundEffect->setLoopCount(QSoundEffect::Infinite); soundEffect->setVolume(50); soundEffect->play();And the audio is not playing. The error what the Qt write out:
QSoundEffect(qaudio): Error decoding source d:/QtProjectver200/Android_alarm/RES/alligator3.wavThanks for your help!
-
I download the wav file from here:
https://www.freesoundeffects.com/free-track/alligator3-89353/ -
I download the wav file from here:
https://www.freesoundeffects.com/free-track/alligator3-89353/- Make sure that is the correct path: if it is not
QSoundEffectstill gives this (somewhat misleading) error message. Use e.g.QFile::exists()to verify. - I don't know how this works on Windows, but do you have the necessary decoder for
.wavfiles? - have you tried with another file in a different path? Have you tried with something other than a
.wavfile?
- Make sure that is the correct path: if it is not
-
- Make sure that is the correct path: if it is not
QSoundEffectstill gives this (somewhat misleading) error message. Use e.g.QFile::exists()to verify. - I don't know how this works on Windows, but do you have the necessary decoder for
.wavfiles? - have you tried with another file in a different path? Have you tried with something other than a
.wavfile?
- Yes the QFile::exists() returns true. I tried this way now (the file is in the build folder):
effect.setSource(QUrl::fromLocalFile("engine.wav")); effect.setLoopCount(QSoundEffect::Infinite); effect.setVolume(0.25f); effect.play();The new error is: qt.multimedia.audiooutput: Failed to set up resampler
- Necessary decoder? I don't know what it is, I didn't add anything other than the main QT. I gave to add some decoder?
- Yes I tried with some different paths and i tried with .OGG file too.
- Make sure that is the correct path: if it is not
-
- Yes the QFile::exists() returns true. I tried this way now (the file is in the build folder):
effect.setSource(QUrl::fromLocalFile("engine.wav")); effect.setLoopCount(QSoundEffect::Infinite); effect.setVolume(0.25f); effect.play();The new error is: qt.multimedia.audiooutput: Failed to set up resampler
- Necessary decoder? I don't know what it is, I didn't add anything other than the main QT. I gave to add some decoder?
- Yes I tried with some different paths and i tried with .OGG file too.
-
Yes,
setSource(QUrl::fromLocalFile(...))looks like the correct way to specify a local file. -
qt.multimedia.audiooutput: Failed to set up resampler: Google for exactly that phrase. https://stackoverflow.com/questions/74500509/failed-to-setup-resampler-when-starting-qaudiosink tells you there is a Qt 6.4.x bug for exactly this, refers you to https://bugreports.qt.io/browse/QTBUG-108383 and tells you what to do. The Qt bug report tells you it was fixed in 6.4.3 but not 6.4.2.