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:
https://bugreports.qt-project.org/browse/QTBUG-28948
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:http://stackoverflow.com/questions/14165608/qt5-qsound-does-not-play-all-wave-files
But what about Windows? I would like my code to support both Mac and Windows.
Thank you!
-
I can't think of why it won't play, but as a workaround, try QSoundEffect and/or QMediaPlayer.
-
-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?
-
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?
-
[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.