X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=app%2FMediaPlayer.qml;h=95bc22bc32bab0ec1a12326977e55cc92afacb16;hb=refs%2Fchanges%2F46%2F27646%2F1;hp=cdd9368c5cfa0d29ca9d6697c40586f605ad8b6f;hpb=e8d39ebb00189c47e38992e3923acb4df7a81cc9;p=apps%2Fmediaplayer.git diff --git a/app/MediaPlayer.qml b/app/MediaPlayer.qml index cdd9368..95bc22b 100644 --- a/app/MediaPlayer.qml +++ b/app/MediaPlayer.qml @@ -17,8 +17,7 @@ import QtQuick 2.11 import QtQuick.Layouts 1.11 import QtQuick.Controls 2.4 - -import QtQuick.Window 2.11 +import QtQuick.Window 2.13 import AGL.Demo.Controls 1.0 @@ -47,6 +46,13 @@ ApplicationWindow { } } + Component.onCompleted : { + // Let the mediaplayer backend know we're ready for metadata events + mediaplayer.start() + + VehicleSignals.connect() + } + Connections { target: mediaplayer @@ -82,6 +88,33 @@ ApplicationWindow { } } + 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 @@ -95,8 +128,8 @@ ApplicationWindow { Item { id: container anchors.centerIn: parent - width: Screen.width - height: Screen.height + width: Window.width + height: Window.height //scale: screenInfo.scale_factor() scale: 1