X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=app%2FMediaPlayer.qml;h=fd4db58fe980820be2f62fd5015f50c7dae86058;hb=refs%2Ftags%2Fneedlefish_13.93.0;hp=92e9f392c6d51438d476080a84e62787afaa31db;hpb=8fe37ce16229c6729958e835c389ac347260388c;p=apps%2Fmediaplayer.git diff --git a/app/MediaPlayer.qml b/app/MediaPlayer.qml index 92e9f39..fd4db58 100644 --- a/app/MediaPlayer.qml +++ b/app/MediaPlayer.qml @@ -17,6 +17,8 @@ import QtQuick 2.11 import QtQuick.Layouts 1.11 import QtQuick.Controls 2.4 +import QtQuick.Window 2.13 + import AGL.Demo.Controls 1.0 ApplicationWindow { @@ -44,6 +46,13 @@ ApplicationWindow { } } + Component.onCompleted : { + // Let the mediaplayer backend know we're ready for metadata events + mediaplayer.start() + + VehicleSignals.connect() + } + Connections { target: mediaplayer @@ -64,7 +73,9 @@ ApplicationWindow { player.title = track.title player.album = track.album player.artist = track.artist - player.duration = track.duration + + if ('duration' in track) + player.duration = track.duration if ('index' in track) { playlistview.currentIndex = track.index @@ -77,6 +88,33 @@ ApplicationWindow { } } + Connections { + target: VehicleSignals + + onConnected: { + VehicleSignals.authorize() + } + + onAuthorized: { + VehicleSignals.subscribe("Vehicle.Cabin.SteeringWheel.Switches.Next") + VehicleSignals.subscribe("Vehicle.Cabin.SteeringWheel.Switches.Previous") + VehicleSignals.subscribe("Vehicle.Cabin.SteeringWheel.Switches.Mode") + } + + onSignalNotification: { + if (path === "Vehicle.Cabin.SteeringWheel.Switches.Next" && value === "true") { + mediaplayer.next() + } else if (path === "Vehicle.Cabin.SteeringWheel.Switches.Previous" && value === "true") { + mediaplayer.previous() + } else if (path === "Vehicle.Cabin.SteeringWheel.Switches.Mode" && value === "true") { + if (player.av_connected) + mediaplayer.connect() + else + mediaplayer.disconnect() + } + } + } + Timer { id: timer interval: 250 @@ -90,9 +128,10 @@ ApplicationWindow { Item { id: container anchors.centerIn: parent - width: 1080 - height: 1487 - scale: screenInfo.scale_factor() + width: Window.width + height: Window.height + //scale: screenInfo.scale_factor() + scale: 1 ColumnLayout { anchors.fill: parent @@ -101,17 +140,19 @@ ApplicationWindow { Layout.fillHeight: true Layout.preferredHeight: 1080 clip: true + Image { + anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right - anchors.bottom: parent.bottom - height: sourceSize.height * width / sourceSize.width - fillMode: Image.PreserveAspectCrop + anchors.bottom: controls.top + fillMode: Image.PreserveAspectFit source: AlbumArt visible: player.av_connected === false } Item { + id: controls anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom @@ -253,7 +294,7 @@ ApplicationWindow { Item { Layout.fillWidth: true Layout.fillHeight: true - Layout.preferredHeight: 407 + Layout.preferredHeight: 480 ListView { anchors.fill: parent