2 * Copyright (C) 2016 The Qt Company Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 import QtQuick.Layouts 1.11
19 import QtQuick.Controls 2.4
20 import QtQuick.Window 2.13
22 import AGL.Demo.Controls 1.0
27 width: container.width * container.scale
28 height: container.height * container.scale
33 property string title: ""
34 property string album: ""
35 property string artist: ""
37 property bool av_connected: false
39 property int duration: 0
40 property int position: 0
42 property string status: "stopped"
44 function time2str(value) {
45 return Qt.formatTime(new Date(value), (value > 3600000) ? 'hh:mm:ss' : 'mm:ss')
49 Component.onCompleted : {
50 // Let the mediaplayer backend know we're ready for metadata events
53 VehicleSignals.connect()
60 var track = metadata.track
62 if ('status' in metadata) {
63 player.status = metadata.status
66 if ('connected' in metadata) {
67 player.av_connected = metadata.connected
73 player.title = track.title
74 player.album = track.album
75 player.artist = track.artist
77 if ('duration' in track)
78 player.duration = track.duration
80 if ('index' in track) {
81 playlistview.currentIndex = track.index
85 if ('position' in metadata) {
86 player.position = metadata.position
92 target: VehicleSignals
95 VehicleSignals.authorize()
99 VehicleSignals.subscribe("Vehicle.Cabin.Infotainment.Media.Action")
102 onSignalNotification: {
103 if (path === "Vehicle.Cabin.Infotainment.Media.Action") {
104 if (value == "SkipForward") {
106 } else if (value == "SkipBackward") {
107 mediaplayer.previous()
108 } else if (value == "NextSource") {
109 if (player.av_connected)
110 mediaplayer.connect()
112 mediaplayer.disconnect()
121 running: player.av_connected && player.status == "playing"
124 player.position = player.position + 250
130 anchors.centerIn: parent
132 height: Window.height
133 //scale: screenInfo.scale_factor()
139 Layout.fillWidth: true
140 Layout.fillHeight: true
141 Layout.preferredHeight: 1080
144 anchors.left: parent.left
145 anchors.right: parent.right
146 anchors.bottom: parent.bottom
147 height: sourceSize.height * width / sourceSize.width
148 fillMode: Image.PreserveAspectCrop
150 visible: player.av_connected === false
154 anchors.left: parent.left
155 anchors.right: parent.right
156 anchors.bottom: parent.bottom
166 anchors.margins: root.width * 0.02
168 Layout.fillWidth: true
169 Layout.fillHeight: true
174 // visible: bluetooth.connected == false
175 // offImage: './images/AGL_MediaPlayer_Shuffle_Inactive.svg'
176 // onImage: './images/AGL_MediaPlayer_Shuffle_Active.svg'
180 visible: player.av_connected === false
181 offImage: './images/AGL_MediaPlayer_Loop_Inactive.svg'
182 onImage: './images/AGL_MediaPlayer_Loop_Active.svg'
183 onClicked: { mediaplayer.loop(checked ? "playlist" : "off") }
190 Layout.alignment: Layout.Center
192 horizontalAlignment: Label.AlignHCenter
193 verticalAlignment: Label.AlignVCenter
196 Layout.alignment: Layout.Center
198 horizontalAlignment: Label.AlignHCenter
199 verticalAlignment: Label.AlignVCenter
200 font.pixelSize: title.font.pixelSize * 0.6
206 Layout.fillWidth: true
208 enabled: player.av_connected === false
209 value: player.position
212 anchors.left: parent.left
213 anchors.bottom: parent.top
215 text: player.time2str(player.position)
219 anchors.right: parent.right
220 anchors.bottom: parent.top
222 text: player.time2str(player.duration)
224 onPressedChanged: mediaplayer.seek(value)
227 Layout.fillHeight: true
229 // source: './images/AGL_MediaPlayer_Playlist_Inactive.svg'
232 // source: './images/AGL_MediaPlayer_CD_Inactive.svg'
234 Item { Layout.fillWidth: true }
237 offImage: './images/AGL_MediaPlayer_BackArrow.svg'
239 mediaplayer.previous()
246 when: player.status == "playing"
249 offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
256 when: player.status != "playing"
259 offImage: './images/AGL_MediaPlayer_Player_Play.svg'
260 onClicked: mediaplayer.play()
267 offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
273 Item { Layout.fillWidth: true }
277 checked: player.av_connected
280 mediaplayer.connect()
282 mediaplayer.disconnect()
285 source: player.av_connected ? './images/AGL_MediaPlayer_Bluetooth_Active.svg' : './images/AGL_MediaPlayer_Bluetooth_Inactive.svg'
293 Layout.fillWidth: true
294 Layout.fillHeight: true
295 Layout.preferredHeight: 407
300 visible: player.av_connected === false
307 model: MediaplayerModel
310 delegate: MouseArea {
312 width: ListView.view.width
313 height: ListView.view.height / 4
316 anchors.leftMargin: 50
317 anchors.rightMargin: 50
319 Layout.fillWidth: true
321 Layout.fillWidth: true
325 Layout.fillWidth: true
332 // text: player.time2str(model.duration)
334 // font.pixelSize: 32
338 mediaplayer.picktrack(playlistview.model[index].index)
342 highlight: Rectangle {