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')
49 Component.onCompleted : {
50 // Let the mediaplayer backend know we're ready for metadata events
58 var track = metadata.track
60 if ('status' in metadata) {
61 player.status = metadata.status
64 if ('connected' in metadata) {
65 player.av_connected = metadata.connected
71 player.title = track.title
72 player.album = track.album
73 player.artist = track.artist
75 if ('duration' in track)
76 player.duration = track.duration
78 if ('index' in track) {
79 playlistview.currentIndex = track.index
83 if ('position' in metadata) {
84 player.position = metadata.position
92 running: player.av_connected && player.status == "playing"
95 player.position = player.position + 250
101 anchors.centerIn: parent
103 height: Window.height
104 //scale: screenInfo.scale_factor()
110 Layout.fillWidth: true
111 Layout.fillHeight: true
112 Layout.preferredHeight: 1080
115 anchors.left: parent.left
116 anchors.right: parent.right
117 anchors.bottom: parent.bottom
118 height: sourceSize.height * width / sourceSize.width
119 fillMode: Image.PreserveAspectCrop
121 visible: player.av_connected === false
125 anchors.left: parent.left
126 anchors.right: parent.right
127 anchors.bottom: parent.bottom
137 anchors.margins: root.width * 0.02
139 Layout.fillWidth: true
140 Layout.fillHeight: true
145 // visible: bluetooth.connected == false
146 // offImage: './images/AGL_MediaPlayer_Shuffle_Inactive.svg'
147 // onImage: './images/AGL_MediaPlayer_Shuffle_Active.svg'
151 visible: player.av_connected === false
152 offImage: './images/AGL_MediaPlayer_Loop_Inactive.svg'
153 onImage: './images/AGL_MediaPlayer_Loop_Active.svg'
154 onClicked: { mediaplayer.loop(checked ? "playlist" : "off") }
161 Layout.alignment: Layout.Center
163 horizontalAlignment: Label.AlignHCenter
164 verticalAlignment: Label.AlignVCenter
167 Layout.alignment: Layout.Center
169 horizontalAlignment: Label.AlignHCenter
170 verticalAlignment: Label.AlignVCenter
171 font.pixelSize: title.font.pixelSize * 0.6
177 Layout.fillWidth: true
179 enabled: player.av_connected === false
180 value: player.position
183 anchors.left: parent.left
184 anchors.bottom: parent.top
186 text: player.time2str(player.position)
190 anchors.right: parent.right
191 anchors.bottom: parent.top
193 text: player.time2str(player.duration)
195 onPressedChanged: mediaplayer.seek(value)
198 Layout.fillHeight: true
200 // source: './images/AGL_MediaPlayer_Playlist_Inactive.svg'
203 // source: './images/AGL_MediaPlayer_CD_Inactive.svg'
205 Item { Layout.fillWidth: true }
208 offImage: './images/AGL_MediaPlayer_BackArrow.svg'
210 mediaplayer.previous()
217 when: player.status == "playing"
220 offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
227 when: player.status != "playing"
230 offImage: './images/AGL_MediaPlayer_Player_Play.svg'
231 onClicked: mediaplayer.play()
238 offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
244 Item { Layout.fillWidth: true }
248 checked: player.av_connected
251 mediaplayer.connect()
253 mediaplayer.disconnect()
256 source: player.av_connected ? './images/AGL_MediaPlayer_Bluetooth_Active.svg' : './images/AGL_MediaPlayer_Bluetooth_Inactive.svg'
264 Layout.fillWidth: true
265 Layout.fillHeight: true
266 Layout.preferredHeight: 407
271 visible: player.av_connected === false
278 model: MediaplayerModel
281 delegate: MouseArea {
283 width: ListView.view.width
284 height: ListView.view.height / 4
287 anchors.leftMargin: 50
288 anchors.rightMargin: 50
290 Layout.fillWidth: true
292 Layout.fillWidth: true
296 Layout.fillWidth: true
303 // text: player.time2str(model.duration)
305 // font.pixelSize: 32
309 mediaplayer.picktrack(playlistview.model[index].index)
313 highlight: Rectangle {