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.SteeringWheel.Switches.Next")
100 VehicleSignals.subscribe("Vehicle.Cabin.SteeringWheel.Switches.Previous")
101 VehicleSignals.subscribe("Vehicle.Cabin.SteeringWheel.Switches.Mode")
104 onSignalNotification: {
105 if (path === "Vehicle.Cabin.SteeringWheel.Switches.Next" && value === "true") {
107 } else if (path === "Vehicle.Cabin.SteeringWheel.Switches.Previous" && value === "true") {
108 mediaplayer.previous()
109 } else if (path === "Vehicle.Cabin.SteeringWheel.Switches.Mode" && value === "true") {
110 if (player.av_connected)
111 mediaplayer.connect()
113 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
145 anchors.top: parent.top
146 anchors.left: parent.left
147 anchors.right: parent.right
148 anchors.bottom: controls.top
149 fillMode: Image.PreserveAspectFit
151 visible: player.av_connected === false
156 anchors.left: parent.left
157 anchors.right: parent.right
158 anchors.bottom: parent.bottom
168 anchors.margins: root.width * 0.02
170 Layout.fillWidth: true
171 Layout.fillHeight: true
176 // visible: bluetooth.connected == false
177 // offImage: './images/AGL_MediaPlayer_Shuffle_Inactive.svg'
178 // onImage: './images/AGL_MediaPlayer_Shuffle_Active.svg'
182 visible: player.av_connected === false
183 offImage: './images/AGL_MediaPlayer_Loop_Inactive.svg'
184 onImage: './images/AGL_MediaPlayer_Loop_Active.svg'
185 onClicked: { mediaplayer.loop(checked ? "playlist" : "off") }
192 Layout.alignment: Layout.Center
194 horizontalAlignment: Label.AlignHCenter
195 verticalAlignment: Label.AlignVCenter
198 Layout.alignment: Layout.Center
200 horizontalAlignment: Label.AlignHCenter
201 verticalAlignment: Label.AlignVCenter
202 font.pixelSize: title.font.pixelSize * 0.6
208 Layout.fillWidth: true
210 enabled: player.av_connected === false
211 value: player.position
214 anchors.left: parent.left
215 anchors.bottom: parent.top
217 text: player.time2str(player.position)
221 anchors.right: parent.right
222 anchors.bottom: parent.top
224 text: player.time2str(player.duration)
226 onPressedChanged: mediaplayer.seek(value)
229 Layout.fillHeight: true
231 // source: './images/AGL_MediaPlayer_Playlist_Inactive.svg'
234 // source: './images/AGL_MediaPlayer_CD_Inactive.svg'
236 Item { Layout.fillWidth: true }
239 offImage: './images/AGL_MediaPlayer_BackArrow.svg'
241 mediaplayer.previous()
248 when: player.status == "playing"
251 offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
258 when: player.status != "playing"
261 offImage: './images/AGL_MediaPlayer_Player_Play.svg'
262 onClicked: mediaplayer.play()
269 offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
275 Item { Layout.fillWidth: true }
279 checked: player.av_connected
282 mediaplayer.connect()
284 mediaplayer.disconnect()
287 source: player.av_connected ? './images/AGL_MediaPlayer_Bluetooth_Active.svg' : './images/AGL_MediaPlayer_Bluetooth_Inactive.svg'
295 Layout.fillWidth: true
296 Layout.fillHeight: true
297 Layout.preferredHeight: 480
302 visible: player.av_connected === false
309 model: MediaplayerModel
312 delegate: MouseArea {
314 width: ListView.view.width
315 height: ListView.view.height / 4
318 anchors.leftMargin: 50
319 anchors.rightMargin: 50
321 Layout.fillWidth: true
323 Layout.fillWidth: true
327 Layout.fillWidth: true
334 // text: player.time2str(model.duration)
336 // font.pixelSize: 32
340 mediaplayer.picktrack(playlistview.model[index].index)
344 highlight: Rectangle {