Sound using QMediaPlayer on android
-
So i am working on a game that needs sound effects. i have gone through a bunch of different methods of playing sound, and i finally managed to play sounds using QMediaPlayer (on pc) with audio files in a resource. Unfortunately this doesn't seem to be working at all on android (there is no sound). any ideas?
i did a lot of googling on this and i dont think anyone has come up with a real answer that just works.
-
Hi, and welcome to the Qt forum! Have you tried QAudioOutput? Should be working on Android since Qt 5.2 (see: http://doc.qt.io/qt-5/whatsnew52.html).
-
@Wieland does it work with files in the resources? also it seems much more complicated than just passing a qrc url into a set function and then calling play.
-
QMediaPlayer should also work (https://www.kdab.com/qt-on-android-episode-1/)... Are you sure your Android device has the necessary codecs installed?
does it work with files in the resources?
Can't test it right now but I don't see a reason why it shouldn't work as it operates on
QIODevice
. -
@Wieland okay, i read up on the topic a little more, it seems like there is some sort of bug with setting the volume using setVolume on QMediaPlayer. i had to manually set the volume on a different program. is there a way to classify your qt app as a media program so it knows to change media volume? if i hit the volume rocker it increases my notification sound but not media sound.