⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)
QSound on Qt 5.2.1 does not play .wav files
I just recently ported my code from Qt 4.8.5 to Qt 5.2.1 (desktop version). I found all the .wav files that used to play in 4.8.5 do not play any more in 5.2.1, even though I've added multimedia module. I'm sure this has been reported by others as seen here:
It says the bug has been fixed. But why I'm still getting it in Qt 5.2.1? There is also a solution for Mac as described here:
But what about Windows? I would like my code to support both Mac and Windows.
Sorry, I take it back, they do play in Windows. But still not play in Mac for me.
I can't think of why it won't play, but as a workaround, try QSoundEffect and/or QMediaPlayer.
As far as I know, QSound is just a wrap around QSoundEffect in Qt5, so that does not work (I did try it and got the same result).
-QSound and QSoundEffect are unrelated classes.- EDIT: Oops, you're right. However, QSoundEffect has gives you more access to its internals.
- What does QSoundEffect::supportedMimeTypes() return?
- After you try to play, what does QSoundEffect::status() return?
"audio/x-wav", "audio/wav", "audio/wave", "audio/x-pn-wav"
status() returns 2, meaning "ready to play"? But I called play()...
Actually, connect the statusChanged() signal to a slot that prints the status. (The playback is asynchronous, so if you call status() immediately after play() you won't see anything). What different statuses do you get?
Also, have you tried QMediaPlayer, and/or the Audacity trick?
I did print from a connected slot. It prints 1 and then 2. That's it.
What is Audacity trick? QMediaPlayer sounds really like a overkill to just play a single beep : (.
[quote author="rushmore" date="1398956657"]I did print from a connected slot. It prints 1 and then 2. That's it.[/quote]Sounds like there's a bug. If you submit a bug report and attach your .wav file, someone who works on Qt Multimedia will look into it.
[quote]What is Audacity trick?[/quote]See the 1st answer in your StackOverflow link. Basically, use http://audacity.sourceforge.net/ to open and re-save your .wav file. If the problem is caused by missing headers, this trick should restore them.
[quote]QMediaPlayer sounds really like a overkill to just play a single beep : (. [/quote]I agree. But it's better than having no sound.
Audacity trick didn't help unfortunately. I think I will need to file a bug report.