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 status: "stopped"
42 function time2str(value) {
43 return Qt.formatTime(new Date(value), '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
62 player.title = track.title
63 player.album = track.album
64 player.artist = track.artist
65 player.duration = track.duration
67 if ('index' in track) {
68 playlistview.currentIndex = track.index
72 if ('position' in metadata) {
73 player.position = metadata.position
81 running: player.av_connected && player.status == "playing"
84 player.position = player.position + 250
90 anchors.centerIn: parent
93 scale: screenInfo.scale_factor()
98 Layout.fillWidth: true
99 Layout.fillHeight: true
100 Layout.preferredHeight: 1080
103 anchors.left: parent.left
104 anchors.right: parent.right
105 anchors.bottom: parent.bottom
106 height: sourceSize.height * width / sourceSize.width
107 fillMode: Image.PreserveAspectCrop
109 visible: player.av_connected === false
113 anchors.left: parent.left
114 anchors.right: parent.right
115 anchors.bottom: parent.bottom
125 anchors.margins: root.width * 0.02
127 Layout.fillWidth: true
128 Layout.fillHeight: true
133 // visible: bluetooth.connected == false
134 // offImage: './images/AGL_MediaPlayer_Shuffle_Inactive.svg'
135 // onImage: './images/AGL_MediaPlayer_Shuffle_Active.svg'
139 visible: player.av_connected === false
140 offImage: './images/AGL_MediaPlayer_Loop_Inactive.svg'
141 onImage: './images/AGL_MediaPlayer_Loop_Active.svg'
142 onClicked: { mediaplayer.loop(checked) }
149 Layout.alignment: Layout.Center
151 horizontalAlignment: Label.AlignHCenter
152 verticalAlignment: Label.AlignVCenter
155 Layout.alignment: Layout.Center
157 horizontalAlignment: Label.AlignHCenter
158 verticalAlignment: Label.AlignVCenter
159 font.pixelSize: title.font.pixelSize * 0.6
165 Layout.fillWidth: true
167 enabled: player.av_connected === false
168 value: player.position
171 anchors.left: parent.left
172 anchors.bottom: parent.top
174 text: player.time2str(player.position)
178 anchors.right: parent.right
179 anchors.bottom: parent.top
181 text: player.time2str(player.duration)
183 onPressedChanged: mediaplayer.seek(value)
186 Layout.fillHeight: true
188 // source: './images/AGL_MediaPlayer_Playlist_Inactive.svg'
191 // source: './images/AGL_MediaPlayer_CD_Inactive.svg'
193 Item { Layout.fillWidth: true }
196 offImage: './images/AGL_MediaPlayer_BackArrow.svg'
199 mediaplayer.previous()
206 when: player.status == "playing"
209 offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
216 when: player.status != "playing"
219 offImage: './images/AGL_MediaPlayer_Player_Play.svg'
230 offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
237 Item { Layout.fillWidth: true }
241 checked: player.av_connected
244 mediaplayer.connect()
246 mediaplayer.disconnect()
249 source: player.av_connected ? './images/AGL_MediaPlayer_Bluetooth_Active.svg' : './images/AGL_MediaPlayer_Bluetooth_Inactive.svg'
257 Layout.fillWidth: true
258 Layout.fillHeight: true
259 Layout.preferredHeight: 407
264 visible: player.av_connected === false
271 model: MediaplayerModel
274 delegate: MouseArea {
276 width: ListView.view.width
277 height: ListView.view.height / 4
280 anchors.leftMargin: 50
281 anchors.rightMargin: 50
283 Layout.fillWidth: true
285 Layout.fillWidth: true
289 Layout.fillWidth: true
296 // text: player.time2str(model.duration)
298 // font.pixelSize: 32
303 mediaplayer.picktrack(playlistview.model[index].index)
307 highlight: Rectangle {