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=089fcd01e4c9ecb73590233df4ddeffdc6e24502;hpb=ffe767784bf30f8f69300ecb3a4d4571ba4d92d6;p=apps%2Fmediaplayer.git diff --git a/app/MediaPlayer.qml b/app/MediaPlayer.qml index 089fcd0..95bc22b 100644 --- a/app/MediaPlayer.qml +++ b/app/MediaPlayer.qml @@ -14,9 +14,11 @@ * limitations under the License. */ -import QtQuick 2.6 -import QtQuick.Layouts 1.1 -import QtQuick.Controls 2.0 +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 { @@ -40,10 +42,17 @@ ApplicationWindow { property string status: "stopped" function time2str(value) { - return Qt.formatTime(new Date(value), 'mm:ss') + return Qt.formatTime(new Date(value), (value > 3600000) ? 'hh:mm:ss' : 'mm:ss') } } + Component.onCompleted : { + // Let the mediaplayer backend know we're ready for metadata events + mediaplayer.start() + + VehicleSignals.connect() + } + Connections { target: mediaplayer @@ -59,10 +68,14 @@ ApplicationWindow { } if (track) { + if ('image' in track) + return 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 @@ -75,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 @@ -88,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