Component.onCompleted : {
// Let the mediaplayer backend know we're ready for metadata events
mediaplayer.start()
+
+ VehicleSignals.connect()
}
Connections {
}
}
+ Connections {
+ target: VehicleSignals
+
+ onConnected: {
+ VehicleSignals.authorize()
+ }
+
+ onAuthorized: {
+ VehicleSignals.subscribe("Vehicle.Cabin.Infotainment.Media.Action")
+ }
+
+ onSignalNotification: {
+ if (path === "Vehicle.Cabin.Infotainment.Media.Action") {
+ if (value == "SkipForward") {
+ mediaplayer.next()
+ } else if (value == "SkipBackward") {
+ mediaplayer.previous()
+ } else if (value == "NextSource") {
+ if (player.av_connected)
+ mediaplayer.connect()
+ else
+ mediaplayer.disconnect()
+ }
+ }
+ }
+ }
+
Timer {
id: timer
interval: 250
QT = qml quickcontrols2
CONFIG += c++11 link_pkgconfig
-PKGCONFIG += qtappfw-mediaplayer
+PKGCONFIG += qtappfw-mediaplayer qtappfw-vehicle-signals
SOURCES = main.cpp
#include <QQuickWindow>
#include <mediaplayer.h>
+#include <vehiclesignals.h>
#include <unistd.h>
QQmlContext *context = engine.rootContext();
context->setContextProperty("AlbumArt", "");
context->setContextProperty("mediaplayer", new Mediaplayer(context));
+ VehicleSignalsConfig vsConfig("mediaplayer");
+ context->setContextProperty("VehicleSignals", new VehicleSignals(vsConfig));
engine.load(QUrl(QStringLiteral("qrc:/MediaPlayer.qml")));