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.1
19 import QtQuick.Controls 2.0
20 import AGL.Demo.Controls 1.0
25 width: container.width * container.scale
26 height: container.height * container.scale
31 property string title: ""
32 property string album: ""
33 property string artist: ""
35 property bool av_connected: false
37 property int duration: 0
38 property int position: 0
40 property string cover_art: ""
41 property string status: "stopped"
43 function time2str(value) {
44 return Qt.formatTime(new Date(value), 'mm:ss')
52 var track = metadata.track
54 if ('status' in metadata) {
55 player.status = metadata.status
58 if ('connected' in metadata) {
59 player.av_connected = metadata.connected
63 if ('image' in track) {
64 player.cover_art = track.image
67 player.title = track.title
68 player.album = track.album
69 player.artist = track.artist
70 player.duration = track.duration
72 if ('index' in track) {
73 playlistview.currentIndex = track.index
77 if ('position' in metadata) {
78 player.position = metadata.position
86 running: player.av_connected && player.status == "playing"
89 player.position = player.position + 250
95 anchors.centerIn: parent
98 scale: screenInfo.scale_factor()
103 Layout.fillWidth: true
104 Layout.fillHeight: true
105 Layout.preferredHeight: 1080
109 anchors.left: parent.left
110 anchors.right: parent.right
111 anchors.bottom: parent.bottom
112 height: sourceSize.height * width / sourceSize.width
113 fillMode: Image.PreserveAspectCrop
114 source: player.cover_art ? player.cover_art : ''
115 visible: player.av_connected === false
119 anchors.left: parent.left
120 anchors.right: parent.right
121 anchors.bottom: parent.bottom
131 anchors.margins: root.width * 0.02
133 Layout.fillWidth: true
134 Layout.fillHeight: true
139 // visible: bluetooth.connected == false
140 // offImage: './images/AGL_MediaPlayer_Shuffle_Inactive.svg'
141 // onImage: './images/AGL_MediaPlayer_Shuffle_Active.svg'
145 visible: player.av_connected === false
146 offImage: './images/AGL_MediaPlayer_Loop_Inactive.svg'
147 onImage: './images/AGL_MediaPlayer_Loop_Active.svg'
148 onClicked: { mediaplayer.loop(checked) }
155 Layout.alignment: Layout.Center
157 horizontalAlignment: Label.AlignHCenter
158 verticalAlignment: Label.AlignVCenter
161 Layout.alignment: Layout.Center
163 horizontalAlignment: Label.AlignHCenter
164 verticalAlignment: Label.AlignVCenter
165 font.pixelSize: title.font.pixelSize * 0.6
171 Layout.fillWidth: true
173 enabled: player.av_connected === false
174 value: player.position
177 anchors.left: parent.left
178 anchors.bottom: parent.top
180 text: player.time2str(player.position)
184 anchors.right: parent.right
185 anchors.bottom: parent.top
187 text: player.time2str(player.duration)
189 onPressedChanged: mediaplayer.seek(value)
192 Layout.fillHeight: true
194 // source: './images/AGL_MediaPlayer_Playlist_Inactive.svg'
197 // source: './images/AGL_MediaPlayer_CD_Inactive.svg'
199 Item { Layout.fillWidth: true }
202 offImage: './images/AGL_MediaPlayer_BackArrow.svg'
204 mediaplayer.previous()
211 when: player.status == "playing"
214 offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
221 when: player.status != "playing"
224 offImage: './images/AGL_MediaPlayer_Player_Play.svg'
225 onClicked: mediaplayer.play()
232 offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
238 Item { Layout.fillWidth: true }
242 checked: player.av_connected
245 mediaplayer.connect()
247 mediaplayer.disconnect()
250 source: player.av_connected ? './images/AGL_MediaPlayer_Bluetooth_Active.svg' : './images/AGL_MediaPlayer_Bluetooth_Inactive.svg'
258 Layout.fillWidth: true
259 Layout.fillHeight: true
260 Layout.preferredHeight: 407
265 visible: player.av_connected === false
272 model: MediaplayerModel
275 delegate: MouseArea {
277 width: ListView.view.width
278 height: ListView.view.height / 4
281 anchors.leftMargin: 50
282 anchors.rightMargin: 50
284 Layout.fillWidth: true
286 Layout.fillWidth: true
290 Layout.fillWidth: true
297 // text: player.time2str(model.duration)
299 // font.pixelSize: 32
303 mediaplayer.picktrack(playlistview.model[index].index)
307 highlight: Rectangle {