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
71 if ('duration' in track)
72 player.duration = track.duration
74 if ('index' in track) {
75 playlistview.currentIndex = track.index
79 if ('position' in metadata) {
80 player.position = metadata.position
88 running: player.av_connected && player.status == "playing"
91 player.position = player.position + 250
97 anchors.centerIn: parent
100 //scale: screenInfo.scale_factor()
106 Layout.fillWidth: true
107 Layout.fillHeight: true
108 Layout.preferredHeight: 1080
111 anchors.left: parent.left
112 anchors.right: parent.right
113 anchors.bottom: parent.bottom
114 height: sourceSize.height * width / sourceSize.width
115 fillMode: Image.PreserveAspectCrop
117 visible: player.av_connected === false
121 anchors.left: parent.left
122 anchors.right: parent.right
123 anchors.bottom: parent.bottom
133 anchors.margins: root.width * 0.02
135 Layout.fillWidth: true
136 Layout.fillHeight: true
141 // visible: bluetooth.connected == false
142 // offImage: './images/AGL_MediaPlayer_Shuffle_Inactive.svg'
143 // onImage: './images/AGL_MediaPlayer_Shuffle_Active.svg'
147 visible: player.av_connected === false
148 offImage: './images/AGL_MediaPlayer_Loop_Inactive.svg'
149 onImage: './images/AGL_MediaPlayer_Loop_Active.svg'
150 onClicked: { mediaplayer.loop(checked ? "playlist" : "off") }
157 Layout.alignment: Layout.Center
159 horizontalAlignment: Label.AlignHCenter
160 verticalAlignment: Label.AlignVCenter
163 Layout.alignment: Layout.Center
165 horizontalAlignment: Label.AlignHCenter
166 verticalAlignment: Label.AlignVCenter
167 font.pixelSize: title.font.pixelSize * 0.6
173 Layout.fillWidth: true
175 enabled: player.av_connected === false
176 value: player.position
179 anchors.left: parent.left
180 anchors.bottom: parent.top
182 text: player.time2str(player.position)
186 anchors.right: parent.right
187 anchors.bottom: parent.top
189 text: player.time2str(player.duration)
191 onPressedChanged: mediaplayer.seek(value)
194 Layout.fillHeight: true
196 // source: './images/AGL_MediaPlayer_Playlist_Inactive.svg'
199 // source: './images/AGL_MediaPlayer_CD_Inactive.svg'
201 Item { Layout.fillWidth: true }
204 offImage: './images/AGL_MediaPlayer_BackArrow.svg'
206 mediaplayer.previous()
213 when: player.status == "playing"
216 offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
223 when: player.status != "playing"
226 offImage: './images/AGL_MediaPlayer_Player_Play.svg'
227 onClicked: mediaplayer.play()
234 offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
240 Item { Layout.fillWidth: true }
244 checked: player.av_connected
247 mediaplayer.connect()
249 mediaplayer.disconnect()
252 source: player.av_connected ? './images/AGL_MediaPlayer_Bluetooth_Active.svg' : './images/AGL_MediaPlayer_Bluetooth_Inactive.svg'
260 Layout.fillWidth: true
261 Layout.fillHeight: true
262 Layout.preferredHeight: 407
267 visible: player.av_connected === false
274 model: MediaplayerModel
277 delegate: MouseArea {
279 width: ListView.view.width
280 height: ListView.view.height / 4
283 anchors.leftMargin: 50
284 anchors.rightMargin: 50
286 Layout.fillWidth: true
288 Layout.fillWidth: true
292 Layout.fillWidth: true
299 // text: player.time2str(model.duration)
301 // font.pixelSize: 32
305 mediaplayer.picktrack(playlistview.model[index].index)
309 highlight: Rectangle {