summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortiansen <tian_sen@dl.cn.nexty-ele.com>2018-11-02 20:08:00 +0800
committertiansen <tian_sen@dl.cn.nexty-ele.com>2018-11-02 20:08:00 +0800
commitc9758737aac76866a6f549d47d9059558a5d9685 (patch)
treedf11f3345a85b98997f6f0db431949e2f217e7b7
parent64551c373988866607cc4af49e8b3e55aa0d218e (diff)
-rw-r--r--app/VideoPlayer.qml192
-rw-r--r--app/app.pro5
-rw-r--r--app/main.cpp125
-rw-r--r--app/pkg-config_wrapper.sh6
-rw-r--r--package/config.xml4
-rw-r--r--sample/videoplayer.bb24
6 files changed, 257 insertions, 99 deletions
diff --git a/app/VideoPlayer.qml b/app/VideoPlayer.qml
index 7eb252e..4fae69d 100644
--- a/app/VideoPlayer.qml
+++ b/app/VideoPlayer.qml
@@ -63,123 +63,126 @@ ApplicationWindow {
Layout.fillHeight: true
Layout.preferredHeight: 1080
clip: true
+
VideoOutput {
source: player
- anchors.top: parent.top
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.bottom: controls.top
+ anchors.fill: parent
Rectangle {
anchors.fill: parent
color: 'black'
opacity: 0.75
z: -1
}
- }
- Item {
- id: controls
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- height: 307
- Rectangle {
+ MouseArea{
anchors.fill: parent
- color: 'black'
- opacity: 0.75
+ onClicked:{
+ controls.visible = !controls.visible;
+ }
}
- ColumnLayout {
- anchors.fill: parent
- anchors.margins: root.width * 0.02
- Item {
- Layout.fillWidth: true
- Layout.fillHeight: true
- Row {
- spacing: 20
- ToggleButton {
- id: random
- offImage: './images/AGL_MediaPlayer_Shuffle_Inactive.svg'
- onImage: './images/AGL_MediaPlayer_Shuffle_Active.svg'
+ Item {
+ id: controls
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ visible: false
+ height: 240
+ z: 100
+
+ ColumnLayout {
+ anchors.fill: parent
+ anchors.margins: 5
+ Item {
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Row {
+ spacing: 20
+ ToggleButton {
+ id: random
+ offImage: './images/AGL_MediaPlayer_Shuffle_Inactive.svg'
+ onImage: './images/AGL_MediaPlayer_Shuffle_Active.svg'
+ }
+ ToggleButton {
+ id: loop
+ offImage: './images/AGL_MediaPlayer_Loop_Inactive.svg'
+ onImage: './images/AGL_MediaPlayer_Loop_Active.svg'
+ }
}
- ToggleButton {
- id: loop
- offImage: './images/AGL_MediaPlayer_Loop_Inactive.svg'
- onImage: './images/AGL_MediaPlayer_Loop_Active.svg'
+ ColumnLayout {
+ anchors.fill: parent
+ Label {
+ id: title
+ Layout.alignment: Layout.Center
+ text: player.metaData.title ? player.metaData.title : ''
+ horizontalAlignment: Label.AlignHCenter
+ verticalAlignment: Label.AlignVCenter
+ }
+ Label {
+ id: artist
+ Layout.alignment: Layout.Center
+ text: player.metaData.author ? player.metaData.author : ''
+ horizontalAlignment: Label.AlignHCenter
+ verticalAlignment: Label.AlignVCenter
+ font.pixelSize: title.font.pixelSize * 0.6
+ }
}
}
- ColumnLayout {
- anchors.fill: parent
+ Slider {
+ id: slider
+ Layout.fillWidth: true
+ to: player.duration
Label {
- id: title
- Layout.alignment: Layout.Center
- text: player.metaData.title ? player.metaData.title : ''
- horizontalAlignment: Label.AlignHCenter
- verticalAlignment: Label.AlignVCenter
+ id: position
+ anchors.left: parent.left
+ anchors.bottom: parent.top
+ font.pixelSize: 24
+ text: player.time2str(player.position)
}
Label {
- id: artist
- Layout.alignment: Layout.Center
- text: player.metaData.author ? player.metaData.author : ''
- horizontalAlignment: Label.AlignHCenter
- verticalAlignment: Label.AlignVCenter
- font.pixelSize: title.font.pixelSize * 0.6
+ id: duration
+ anchors.right: parent.right
+ anchors.bottom: parent.top
+ font.pixelSize: 24
+ text: player.time2str(player.duration)
}
+ onPressedChanged: player.seek(value)
}
- }
- Slider {
- id: slider
- Layout.fillWidth: true
- to: player.duration
- Label {
- id: position
- anchors.left: parent.left
- anchors.bottom: parent.top
- font.pixelSize: 32
- text: player.time2str(player.position)
- }
- Label {
- id: duration
- anchors.right: parent.right
- anchors.bottom: parent.top
- font.pixelSize: 32
- text: player.time2str(player.duration)
- }
- onPressedChanged: player.seek(value)
- }
- RowLayout {
- Layout.fillHeight: true
- Item { Layout.fillWidth: true }
- ImageButton {
- offImage: './images/AGL_MediaPlayer_BackArrow.svg'
- onClicked: playlist.previous()
- }
- ImageButton {
- id: play
- offImage: './images/AGL_MediaPlayer_Player_Play.svg'
- onClicked: player.play()
- states: [
- State {
- when: player.playbackState === MediaPlayer.PlayingState
- PropertyChanges {
- target: play
- offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
- onClicked: player.pause()
+ RowLayout {
+ Layout.fillHeight: true
+ Item { Layout.fillWidth: true }
+ ImageButton {
+ offImage: './images/AGL_MediaPlayer_BackArrow.svg'
+ onClicked: playlist.previous()
+ }
+ ImageButton {
+ id: play
+ offImage: './images/AGL_MediaPlayer_Player_Play.svg'
+ onClicked: player.play()
+ states: [
+ State {
+ when: player.playbackState === MediaPlayer.PlayingState
+ PropertyChanges {
+ target: play
+ offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
+ onClicked: player.pause()
+ }
}
- }
- ]
- }
- ImageButton {
- offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
- onClicked: playlist.next()
- }
+ ]
+ }
+ ImageButton {
+ offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
+ onClicked: playlist.next()
+ }
- Item { Layout.fillWidth: true }
+ Item { Layout.fillWidth: true }
+ }
}
}
}
}
Item {
+ id: playlistArea
Layout.fillWidth: true
Layout.fillHeight: true
Layout.preferredHeight: 407
@@ -229,4 +232,13 @@ ApplicationWindow {
}
}
}
+
+
+ function changeArea(area) {
+ if (area === 'normal') {
+ playlistArea.visible = true;
+ } else {
+ playlistArea.visible = false;
+ }
+ }
}
diff --git a/app/app.pro b/app/app.pro
index eeb139c..fdb0bc2 100644
--- a/app/app.pro
+++ b/app/app.pro
@@ -1,8 +1,11 @@
TARGET = videoplayer
-QT = quick aglextras multimedia
+QT = quickcontrols2 multimedia
SOURCES = main.cpp
+CONFIG += link_pkgconfig
+PKGCONFIG += libhomescreen qlibwindowmanager
+
RESOURCES += \
videoplayer.qrc \
images/images.qrc
diff --git a/app/main.cpp b/app/main.cpp
index 7fdff20..8227411 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -13,14 +13,127 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <QtAGLExtras/AGLApplication>
+// #include <QtAGLExtras/AGLApplication>
+#include <QtQml/qqml.h>
+#include <qlibwindowmanager.h>
+#include <QQuickWindow>
+#include <QtCore/QCommandLineParser>
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
+#include <QtCore/QStandardPaths>
+#include <QtCore/QUrlQuery>
+#include <QtGui/QGuiApplication>
#include <QtQml/QQmlApplicationEngine>
+#include <QtQml/QQmlContext>
+#include <QtQuickControls2/QQuickStyle>
+#include <libhomescreen.hpp>
+
+int main(int argc, char* argv[]) {
+ // AGLApplication app(argc, argv);
+ // app.setApplicationName("VideoPlayer");
+ // app.setupApplicationRole("Video");
+ // app.load(QUrl(QStringLiteral("qrc:/VideoPlayer.qml")));
+ // return app.exec();
+
+ QString role = QString("Video");
+ QGuiApplication app(argc, argv);
-int main(int argc, char *argv[])
-{
- AGLApplication app(argc, argv);
app.setApplicationName("VideoPlayer");
- app.setupApplicationRole("Video");
- app.load(QUrl(QStringLiteral("qrc:/VideoPlayer.qml")));
+
+ QQuickStyle::setStyle("AGL");
+
+ QQmlApplicationEngine engine;
+ QQmlContext* context = engine.rootContext();
+
+ QCommandLineParser parser;
+ parser.addPositionalArgument("port",
+ app.translate("main", "port for binding"));
+ parser.addPositionalArgument("secret",
+ app.translate("main", "secret for binding"));
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.process(app);
+ QStringList positionalArguments = parser.positionalArguments();
+
+ if (positionalArguments.length() == 2) {
+ int port = positionalArguments.takeFirst().toInt();
+ QString secret = positionalArguments.takeFirst();
+ QUrl bindingAddress;
+ bindingAddress.setScheme(QStringLiteral("ws"));
+ bindingAddress.setHost(QStringLiteral("localhost"));
+ bindingAddress.setPort(port);
+ bindingAddress.setPath(QStringLiteral("/api"));
+ QUrlQuery query;
+ query.addQueryItem(QStringLiteral("token"), secret);
+ bindingAddress.setQuery(query);
+ context->setContextProperty(QStringLiteral("bindingAddress"),
+ bindingAddress);
+ std::string token = secret.toStdString();
+ LibHomeScreen* hs = new LibHomeScreen();
+ QLibWindowmanager* qwm = new QLibWindowmanager();
+
+ QString area;
+
+ // WindowManager
+ if (qwm->init(port, secret) != 0) {
+ exit(EXIT_FAILURE);
+ }
+ // Request a surface as described in layers.json windowmanager’s file
+ if (qwm->requestSurface(role) != 0) {
+ exit(EXIT_FAILURE);
+ }
+
+ engine.load(QUrl(QStringLiteral("qrc:/VideoPlayer.qml")));
+ QObject* root = engine.rootObjects().first();
+
+ // Create an event callback against an event type. Here a lambda is
+ // called when SyncDraw event occurs
+ qwm->set_event_handler(
+ QLibWindowmanager::Event_SyncDraw,
+ [qwm, role, &area, root](json_object* object) {
+ fprintf(stderr, "Surface got syncDraw!\n");
+
+ // get area
+ json_object* areaJ = nullptr;
+ if (json_object_object_get_ex(object, "drawing_area", &areaJ)) {
+ area = QLatin1String(json_object_get_string(areaJ));
+
+ QMetaObject::invokeMethod(root, "changeArea",
+ Q_ARG(QVariant, area));
+ }
+
+ qwm->endDraw(role);
+ });
+
+ // HomeScreen
+ hs->init(port, token.c_str());
+ // Set the event handler for Event_TapShortcut which will activate the
+ // surface for windowmanager
+ hs->set_event_handler(
+ LibHomeScreen::Event_TapShortcut, [qwm, role](json_object* object) {
+ qDebug("Surface Video got tapShortcut\n");
+ qwm->activateSurface(role);
+ });
+
+ // Set the event handler for Event_Restriction which will allocate or
+ // release restriction area for homescreen
+ qwm->set_event_handler(
+ QLibWindowmanager::Event_LightstatusBrakeOff,
+ [hs, &area](json_object* object) {
+ qDebug() << "Event_LightstatusBrakeOff!";
+ hs->allocateRestriction(area.toStdString().c_str());
+ });
+
+ qwm->set_event_handler(
+ QLibWindowmanager::Event_LightstatusBrakeOn,
+ [hs, &area](json_object* object) {
+ qDebug() << "Event_LightstatusBrakeOn!";
+ hs->releaseRestriction(area.toStdString().c_str());
+ });
+
+ QQuickWindow* window = qobject_cast<QQuickWindow*>(root);
+ QObject::connect(window, SIGNAL(frameSwapped()), qwm,
+ SLOT(slotActivateSurface()));
+ }
return app.exec();
}
diff --git a/app/pkg-config_wrapper.sh b/app/pkg-config_wrapper.sh
new file mode 100644
index 0000000..02ed39b
--- /dev/null
+++ b/app/pkg-config_wrapper.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+PKG_CONFIG_SYSROOT_DIR=/opt/sdk/sysroots/aarch64-agl-linux
+export PKG_CONFIG_SYSROOT_DIR
+PKG_CONFIG_LIBDIR=/opt/sdk/sysroots/aarch64-agl-linux/usr/lib/pkgconfig:/opt/sdk/sysroots/aarch64-agl-linux/usr/share/pkgconfig
+export PKG_CONFIG_LIBDIR
+exec pkg-config "$@"
diff --git a/package/config.xml b/package/config.xml
index e1a64ad..5428a0d 100644
--- a/package/config.xml
+++ b/package/config.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<widget xmlns="http://www.w3.org/ns/widgets" id="videoplayer" version="0.1">
- <name>Video</name>
+<widget xmlns="http://www.w3.org/ns/widgets" id="video" version="0.1">
+ <name>video</name>
<icon src="icon.svg"/>
<content src="bin/videoplayer" type="application/vnd.agl.native"/>
<description>This is a demo videoplayer application</description>
diff --git a/sample/videoplayer.bb b/sample/videoplayer.bb
new file mode 100644
index 0000000..dce0c14
--- /dev/null
+++ b/sample/videoplayer.bb
@@ -0,0 +1,24 @@
+SUMMARY = "Demo app for video player"
+DESCRIPTION = "AGL demo app for video player"
+HOMEPAGE = "http://oss-project.tmc-tokai.jp/gitlab/als2018/videoplayer"
+SECTION = "apps"
+
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=ae6497158920d9524cf208c09cc4c984"
+
+USERNAME = ""
+PASSWORD = ""
+
+SRC_URI = "git://oss-project.tmc-tokai.jp/gitlab/als2018/videoplayer.git;protocol=http;branch=master;user=${USERNAME}:${PASSWORD}"
+SRCREV = "3663a5fb2eb9a7d9ff10a827c605bfe0e929ac90"
+
+PV = "1.0+git${SRCPV}"
+S = "${WORKDIR}/git"
+
+# build-time dependencies
+DEPENDS += "qtquickcontrols2 qtmultimedia virtual/libhomescreen qlibwindowmanager"
+
+# runtime dependencies
+# RDEPENDS_${PN} += ""
+
+inherit qmake5 aglwgt \ No newline at end of file