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')
53 var track = metadata.track
55 if ('status' in metadata) {
56 player.status = metadata.status
59 if ('connected' in metadata) {
60 player.av_connected = metadata.connected
66 player.title = track.title
67 player.album = track.album
68 player.artist = track.artist
70 if ('duration' in track)
71 player.duration = track.duration
73 if ('index' in track) {
74 playlistview.currentIndex = track.index
78 if ('position' in metadata) {
79 player.position = metadata.position
87 running: player.av_connected && player.status == "playing"
90 player.position = player.position + 250
96 anchors.centerIn: parent
99 //scale: screenInfo.scale_factor()
105 Layout.fillWidth: true
106 Layout.fillHeight: true
107 Layout.preferredHeight: 1080
110 anchors.left: parent.left
111 anchors.right: parent.right
112 anchors.bottom: parent.bottom
113 height: sourceSize.height * width / sourceSize.width
114 fillMode: Image.PreserveAspectCrop
116 visible: player.av_connected === false
120 anchors.left: parent.left
121 anchors.right: parent.right
122 anchors.bottom: parent.bottom
132 anchors.margins: root.width * 0.02
134 Layout.fillWidth: true
135 Layout.fillHeight: true
140 // visible: bluetooth.connected == false
141 // offImage: './images/AGL_MediaPlayer_Shuffle_Inactive.svg'
142 // onImage: './images/AGL_MediaPlayer_Shuffle_Active.svg'
146 visible: player.av_connected === false
147 offImage: './images/AGL_MediaPlayer_Loop_Inactive.svg'
148 onImage: './images/AGL_MediaPlayer_Loop_Active.svg'
149 onClicked: { mediaplayer.loop(checked ? "playlist" : "off") }
156 Layout.alignment: Layout.Center
158 horizontalAlignment: Label.AlignHCenter
159 verticalAlignment: Label.AlignVCenter
162 Layout.alignment: Layout.Center
164 horizontalAlignment: Label.AlignHCenter
165 verticalAlignment: Label.AlignVCenter
166 font.pixelSize: title.font.pixelSize * 0.6
172 Layout.fillWidth: true
174 enabled: player.av_connected === false
175 value: player.position
178 anchors.left: parent.left
179 anchors.bottom: parent.top
181 text: player.time2str(player.position)
185 anchors.right: parent.right
186 anchors.bottom: parent.top
188 text: player.time2str(player.duration)
190 onPressedChanged: mediaplayer.seek(value)
193 Layout.fillHeight: true
195 // source: './images/AGL_MediaPlayer_Playlist_Inactive.svg'
198 // source: './images/AGL_MediaPlayer_CD_Inactive.svg'
200 Item { Layout.fillWidth: true }
203 offImage: './images/AGL_MediaPlayer_BackArrow.svg'
205 mediaplayer.previous()
212 when: player.status == "playing"
215 offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
222 when: player.status != "playing"
225 offImage: './images/AGL_MediaPlayer_Player_Play.svg'
226 onClicked: mediaplayer.play()
233 offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
239 Item { Layout.fillWidth: true }
243 checked: player.av_connected
246 mediaplayer.connect()
248 mediaplayer.disconnect()
251 source: player.av_connected ? './images/AGL_MediaPlayer_Bluetooth_Active.svg' : './images/AGL_MediaPlayer_Bluetooth_Inactive.svg'
259 Layout.fillWidth: true
260 Layout.fillHeight: true
261 Layout.preferredHeight: 407
266 visible: player.av_connected === false
273 model: MediaplayerModel
276 delegate: MouseArea {
278 width: ListView.view.width
279 height: ListView.view.height / 4
282 anchors.leftMargin: 50
283 anchors.rightMargin: 50
285 Layout.fillWidth: true
287 Layout.fillWidth: true
291 Layout.fillWidth: true
298 // text: player.time2str(model.duration)
300 // font.pixelSize: 32
304 mediaplayer.picktrack(playlistview.model[index].index)
308 highlight: Rectangle {