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
67 player.duration = track.duration
69 if ('index' in track) {
70 playlistview.currentIndex = track.index
74 if ('position' in metadata) {
75 player.position = metadata.position
83 running: player.av_connected && player.status == "playing"
86 player.position = player.position + 250
92 anchors.centerIn: parent
95 scale: screenInfo.scale_factor()
100 Layout.fillWidth: true
101 Layout.fillHeight: true
102 Layout.preferredHeight: 1080
105 anchors.left: parent.left
106 anchors.right: parent.right
107 anchors.bottom: parent.bottom
108 height: sourceSize.height * width / sourceSize.width
109 fillMode: Image.PreserveAspectCrop
111 visible: player.av_connected === false
115 anchors.left: parent.left
116 anchors.right: parent.right
117 anchors.bottom: parent.bottom
127 anchors.margins: root.width * 0.02
129 Layout.fillWidth: true
130 Layout.fillHeight: true
135 // visible: bluetooth.connected == false
136 // offImage: './images/AGL_MediaPlayer_Shuffle_Inactive.svg'
137 // onImage: './images/AGL_MediaPlayer_Shuffle_Active.svg'
141 visible: player.av_connected === false
142 offImage: './images/AGL_MediaPlayer_Loop_Inactive.svg'
143 onImage: './images/AGL_MediaPlayer_Loop_Active.svg'
144 onClicked: { mediaplayer.loop(checked ? "playlist" : "off") }
151 Layout.alignment: Layout.Center
153 horizontalAlignment: Label.AlignHCenter
154 verticalAlignment: Label.AlignVCenter
157 Layout.alignment: Layout.Center
159 horizontalAlignment: Label.AlignHCenter
160 verticalAlignment: Label.AlignVCenter
161 font.pixelSize: title.font.pixelSize * 0.6
167 Layout.fillWidth: true
169 enabled: player.av_connected === false
170 value: player.position
173 anchors.left: parent.left
174 anchors.bottom: parent.top
176 text: player.time2str(player.position)
180 anchors.right: parent.right
181 anchors.bottom: parent.top
183 text: player.time2str(player.duration)
185 onPressedChanged: mediaplayer.seek(value)
188 Layout.fillHeight: true
190 // source: './images/AGL_MediaPlayer_Playlist_Inactive.svg'
193 // source: './images/AGL_MediaPlayer_CD_Inactive.svg'
195 Item { Layout.fillWidth: true }
198 offImage: './images/AGL_MediaPlayer_BackArrow.svg'
200 mediaplayer.previous()
207 when: player.status == "playing"
210 offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
217 when: player.status != "playing"
220 offImage: './images/AGL_MediaPlayer_Player_Play.svg'
221 onClicked: mediaplayer.play()
228 offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
234 Item { Layout.fillWidth: true }
238 checked: player.av_connected
241 mediaplayer.connect()
243 mediaplayer.disconnect()
246 source: player.av_connected ? './images/AGL_MediaPlayer_Bluetooth_Active.svg' : './images/AGL_MediaPlayer_Bluetooth_Inactive.svg'
254 Layout.fillWidth: true
255 Layout.fillHeight: true
256 Layout.preferredHeight: 407
261 visible: player.av_connected === false
268 model: MediaplayerModel
271 delegate: MouseArea {
273 width: ListView.view.width
274 height: ListView.view.height / 4
277 anchors.leftMargin: 50
278 anchors.rightMargin: 50
280 Layout.fillWidth: true
282 Layout.fillWidth: true
286 Layout.fillWidth: true
293 // text: player.time2str(model.duration)
295 // font.pixelSize: 32
299 mediaplayer.picktrack(playlistview.model[index].index)
303 highlight: Rectangle {