Qt 5.2.1 Android QMediaPlayer - no sound
-
in my case I am using android api 10 and does not work, with api 17 if works great, I just said the debugger that there is nothing NULL:
-
I just found out that Qt Multimedia is not supported on Android (http://qt-project.org/wiki/Qt_for_Android_known_issues) :
"The Qt Multimedia Widgets module is not supported on Android, which means video display is only available using the VideoOutput and Video QML items."
So we have to wait for it to get fixed.
-
I'm not sure, QMediaplayer is included in QtMultimedia, and
'Qt Multimedia Widgets provides additional multimedia-related widgets and controls. The classes expand the capabilities of the Qt Multimedia and Qt Widgets modules.'
I think QtMultimediaWidgets is not necessary for playing wav/mp3 audio.
I'm thinking about using JNI, see the link below.
http://community.kde.org/Necessitas/JNI -
The JNI audioplayer works flawlessly, I've got audio finally working!
There are some drawbacks though,
1)
#include <qplatformnativeinterface.h> does not work, instead use
#include <QtGui/5.2.1/QtGui/qpa/qplatformnativeinterface.h>
2)
it cannot read audiofiles from assets, so I copy them with QFile::copy
from assets to a sdcard directory.
3)
several #ifdef Q_OS_ANDROID necessary in my code,
because I use the QMediaPlayer for other platforms.I still don't understand why QMediaPlayer can't play my .wav files.
-
plis example janbur,
-
I followed the instructions on
http://community.kde.org/Necessitas/JNI
You can also download an example (the simple Audio player) from here.
With the help of this example it's easy to see what you need to do
to include the jni audioplayer in your own software -
I tried the example, but i get following:
@E/Qt ( 8841): ..\untitled7\androidmediaplayer.cpp:144 (jint JNI_OnLoad(JavaVM*, void*)): Can't find QSimpleAudioPlayer class
W/dalvikvm( 8841): JNI_OnLoad returned bad version (-1) in /data/app-lib/org.qtproject.example.untitled7-1/libuntitled7.so 0x4260b580@Qt 5.2.1, Samsung Galaxy III, Android 4.3
-
Did you create the directory structure below, with the .jave file in it ?
Create QSimpleAudioPlayer.java to your project_root/android/src/org/kde/necessitas/origo/
I see that in my project it is without the android folder :
project_root/src/org/kde/necessitas/origo/ -
I did it like in the example
project_root/android/src/org/kde/necessitas/origo/
it tried:
project_root/src/org/kde/necessitas/origo/but the message is the same and the app crashes.
-
Hi,
in may case it works properly with no errors my code:player->setMedia(QUrl("qrc:/new/prefix1/1.mp3")); // ok it works on windows //also works on android