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 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 status: "stopped"
42 function time2str(value) {
43 return Qt.formatTime(new Date(value), (value > 3600000) ? 'hh:mm:ss' : 'mm:ss')
51 var track = metadata.track
53 if ('status' in metadata) {
54 player.status = metadata.status
57 if ('connected' in metadata) {
58 player.av_connected = metadata.connected
64 player.title = track.title
65 player.album = track.album
66 player.artist = track.artist
68 if ('duration' in track)
69 player.duration = track.duration
71 if ('index' in track) {
72 playlistview.currentIndex = track.index
76 if ('position' in metadata) {
77 player.position = metadata.position
85 running: player.av_connected && player.status == "playing"
88 player.position = player.position + 250
94 anchors.centerIn: parent
97 scale: screenInfo.scale_factor()
102 Layout.fillWidth: true
103 Layout.fillHeight: true
104 Layout.preferredHeight: 1080
107 anchors.left: parent.left
108 anchors.right: parent.right
109 anchors.bottom: parent.bottom
110 height: sourceSize.height * width / sourceSize.width
111 fillMode: Image.PreserveAspectCrop
113 visible: player.av_connected === false
117 anchors.left: parent.left
118 anchors.right: parent.right
119 anchors.bottom: parent.bottom
129 anchors.margins: root.width * 0.02
131 Layout.fillWidth: true
132 Layout.fillHeight: true
137 // visible: bluetooth.connected == false
138 // offImage: './images/AGL_MediaPlayer_Shuffle_Inactive.svg'
139 // onImage: './images/AGL_MediaPlayer_Shuffle_Active.svg'
143 visible: player.av_connected === false
144 offImage: './images/AGL_MediaPlayer_Loop_Inactive.svg'
145 onImage: './images/AGL_MediaPlayer_Loop_Active.svg'
146 onClicked: { mediaplayer.loop(checked ? "playlist" : "off") }
153 Layout.alignment: Layout.Center
155 horizontalAlignment: Label.AlignHCenter
156 verticalAlignment: Label.AlignVCenter
159 Layout.alignment: Layout.Center
161 horizontalAlignment: Label.AlignHCenter
162 verticalAlignment: Label.AlignVCenter
163 font.pixelSize: title.font.pixelSize * 0.6
169 Layout.fillWidth: true
171 enabled: player.av_connected === false
172 value: player.position
175 anchors.left: parent.left
176 anchors.bottom: parent.top
178 text: player.time2str(player.position)
182 anchors.right: parent.right
183 anchors.bottom: parent.top
185 text: player.time2str(player.duration)
187 onPressedChanged: mediaplayer.seek(value)
190 Layout.fillHeight: true
192 // source: './images/AGL_MediaPlayer_Playlist_Inactive.svg'
195 // source: './images/AGL_MediaPlayer_CD_Inactive.svg'
197 Item { Layout.fillWidth: true }
200 offImage: './images/AGL_MediaPlayer_BackArrow.svg'
202 mediaplayer.previous()
209 when: player.status == "playing"
212 offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
219 when: player.status != "playing"
222 offImage: './images/AGL_MediaPlayer_Player_Play.svg'
223 onClicked: mediaplayer.play()
230 offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
236 Item { Layout.fillWidth: true }
240 checked: player.av_connected
243 mediaplayer.connect()
245 mediaplayer.disconnect()
248 source: player.av_connected ? './images/AGL_MediaPlayer_Bluetooth_Active.svg' : './images/AGL_MediaPlayer_Bluetooth_Inactive.svg'
256 Layout.fillWidth: true
257 Layout.fillHeight: true
258 Layout.preferredHeight: 407
263 visible: player.av_connected === false
270 model: MediaplayerModel
273 delegate: MouseArea {
275 width: ListView.view.width
276 height: ListView.view.height / 4
279 anchors.leftMargin: 50
280 anchors.rightMargin: 50
282 Layout.fillWidth: true
284 Layout.fillWidth: true
288 Layout.fillWidth: true
295 // text: player.time2str(model.duration)
297 // font.pixelSize: 32
301 mediaplayer.picktrack(playlistview.model[index].index)
305 highlight: Rectangle {