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
21 import QtQuick.Window 2.11
23 import AGL.Demo.Controls 1.0
28 width: container.width * container.scale
29 height: container.height * container.scale
34 property string title: ""
35 property string album: ""
36 property string artist: ""
38 property bool av_connected: false
40 property int duration: 0
41 property int position: 0
43 property string status: "stopped"
45 function time2str(value) {
46 return Qt.formatTime(new Date(value), (value > 3600000) ? 'hh:mm:ss' : 'mm:ss')
54 var track = metadata.track
56 if ('status' in metadata) {
57 player.status = metadata.status
60 if ('connected' in metadata) {
61 player.av_connected = metadata.connected
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()
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 // added button to simulate a close
242 offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
248 Item { Layout.fillWidth: true }
252 checked: player.av_connected
255 mediaplayer.connect()
257 mediaplayer.disconnect()
260 source: player.av_connected ? './images/AGL_MediaPlayer_Bluetooth_Active.svg' : './images/AGL_MediaPlayer_Bluetooth_Inactive.svg'
268 Layout.fillWidth: true
269 Layout.fillHeight: true
270 Layout.preferredHeight: 407
275 visible: player.av_connected === false
282 model: MediaplayerModel
285 delegate: MouseArea {
287 width: ListView.view.width
288 height: ListView.view.height / 4
291 anchors.leftMargin: 50
292 anchors.rightMargin: 50
294 Layout.fillWidth: true
296 Layout.fillWidth: true
300 Layout.fillWidth: true
307 // text: player.time2str(model.duration)
309 // font.pixelSize: 32
313 mediaplayer.picktrack(playlistview.model[index].index)
317 highlight: Rectangle {