-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Make app for Android
Get prebuilt packages for android from http://sourceforge.net/projects/qtav/files/depends/FFmpeg/android/
extract and put include/*
lib/*
to QtInstallDir/{include,lib}
Download the binary archive: QtCreator
Unpack it where you like, e.g. '/opt/qtcreator'
The QtCreator customization is quite minimal. Only paths to sdk, ndk, ant should be specified. And also path to qmake, e.g. /opt/qt5/arm/bin/qmake
There many articles with screenshots explaining this on the Internet.
Now the main things!
Get QtAV:
git clone https://github.com/wang-bin/QtAV
Then launch QtCreator and open the project QtAV ( QtAV.pro). Add Android kit for armeabi-v7a and build the project with the button with a hammer The directory will appear like this: build-QtAV-Android_armeabi_v7a_GCC_4_8_Qt_5_2_1-Release
You would have different dependently on you compiler or if you have specified other name. So, we have two directories:
Run sdk_install.sh
in build dir. This will copy QtAV libraries to Qt dir to make sure we can create apk correctly.
The renderer ids you can use are VideoRendererId_OpenGLWindow, VideoRendererId_OpenGLWidget, VideoRendererId_Widget, VideoRendererId_GraphicsItem
. You can not use GLWidgetRenderer2
because the widget will be covered by other widgets.
qtcreator -> new project -> App -> App Qt Quick Choose, for example Qt Quick 2.2 Check Android kit in the checkbox.
An empty project will be created.
import QtQuick 2.5
import QtQuick.Window 2.2
Window {
visible: true
width: 360
height: 360
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
Text {
text: qsTr("Hello World")
anchors.centerIn: parent
}
}
Change the above into the following:
import QtQuick 2.5
import QtQuick.Window 2.2
import QtAV 1.6
Window {
id: window1
visible: true
width: 360
height: 360
Text {
height: 16
text: qsTr("Qt+QtAV+FFmpeg")
anchors.right: parent.right
anchors.rightMargin: 13
anchors.top: parent.top
anchors.topMargin: 8
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: 68
}
VideoOutput {
anchors.right: parent.right
anchors.rightMargin: 13
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.top: parent.top
anchors.bottomMargin: 15
anchors.leftMargin: 14
anchors.topMargin: 60
source: player
}
AVPlayer {
id: player
source: "http://blablabla/video/test.mp4"
}
MouseArea {
anchors.rightMargin: 0
anchors.bottomMargin: 0
anchors.leftMargin: 0
anchors.topMargin: 0
anchors.fill: parent
onClicked: {
player.play();
}
}
}
Create AndroidManifest with QtCreator. The default settings are acceptable.
Add the following lines to the project file *.pro:
QT += av
Now we can launch it. There will appear the virtual device selection. We can choose any compatible device from the list, or create a new one.
After that there will be the APK-file in the build directory
build-XXXXXX-Android_armeabi_v7a_GCC_4_8_Qt_5_2_1-Release/android-build/bin/QtApp-debug.apk