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 QtMultimedia 5.6
21 import AGL.Demo.Controls 1.0
22 import MediaPlayer 1.0
28 API.LightMediaScanner {
33 API.BluetoothManager {
40 audioRole: MediaPlayer.MusicRole
44 function time2str(value) {
45 return Qt.formatTime(new Date(value), 'mm:ss')
52 running: (bluetooth.av_connected && bluetooth.state == "playing")
55 bluetooth.position = bluetooth.position + 250
56 slider.value = bluetooth.position
62 playbackMode: random.checked ? Playlist.Random : loop.checked ? Playlist.Loop : Playlist.Sequential
69 Layout.fillWidth: true
70 Layout.fillHeight: true
71 Layout.preferredHeight: 1080
75 anchors.left: parent.left
76 anchors.right: parent.right
77 anchors.bottom: parent.bottom
78 height: sourceSize.height * width / sourceSize.width
79 fillMode: Image.PreserveAspectCrop
80 source: player.metaData.coverArtImage ? player.metaData.coverArtImage : ''
81 visible: bluetooth.av_connected == false
85 anchors.left: parent.left
86 anchors.right: parent.right
87 anchors.bottom: parent.bottom
97 anchors.margins: root.width * 0.02
99 Layout.fillWidth: true
100 Layout.fillHeight: true
105 visible: bluetooth.connected == false
106 offImage: './images/AGL_MediaPlayer_Shuffle_Inactive.svg'
107 onImage: './images/AGL_MediaPlayer_Shuffle_Active.svg'
111 visible: bluetooth.connected == false
112 offImage: './images/AGL_MediaPlayer_Loop_Inactive.svg'
113 onImage: './images/AGL_MediaPlayer_Loop_Active.svg'
120 Layout.alignment: Layout.Center
121 text: bluetooth.av_connected ? bluetooth.title : (player.metaData.title ? player.metaData.title : '')
122 horizontalAlignment: Label.AlignHCenter
123 verticalAlignment: Label.AlignVCenter
126 Layout.alignment: Layout.Center
127 text: bluetooth.av_connected ? bluetooth.artist : (player.metaData.contributingArtist ? player.metaData.contributingArtist : '')
128 horizontalAlignment: Label.AlignHCenter
129 verticalAlignment: Label.AlignVCenter
130 font.pixelSize: title.font.pixelSize * 0.6
136 Layout.fillWidth: true
137 to: bluetooth.av_connected ? bluetooth.duration : player.duration
138 enabled: bluetooth.av_connected == false
139 value: bluetooth.av_connected ? bluetooth.position : player.position
140 function getPosition() {
141 if (bluetooth.av_connected) {
142 return player.time2str(bluetooth.position)
144 return player.time2str(player.position)
148 anchors.left: parent.left
149 anchors.bottom: parent.top
151 text: slider.getPosition()
155 anchors.right: parent.right
156 anchors.bottom: parent.top
158 text: bluetooth.av_connected ? player.time2str(bluetooth.duration) : player.time2str(player.duration)
160 onPressedChanged: player.seek(value)
163 Layout.fillHeight: true
165 // source: './images/AGL_MediaPlayer_Playlist_Inactive.svg'
168 // source: './images/AGL_MediaPlayer_CD_Inactive.svg'
170 Item { Layout.fillWidth: true }
173 offImage: './images/AGL_MediaPlayer_BackArrow.svg'
175 if (bluetooth.av_connected) {
176 bluetooth.sendMediaCommand("Previous")
177 bluetooth.position = 0
185 offImage: './images/AGL_MediaPlayer_Player_Play.svg'
187 if (bluetooth.av_connected) {
188 bluetooth.sendMediaCommand("Play")
195 when: player.playbackState === MediaPlayer.PlayingState
198 offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
199 onClicked: player.pause()
203 when: bluetooth.av_connected && bluetooth.state == "playing"
206 offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
207 onClicked: bluetooth.sendMediaCommand("Pause")
215 offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
217 if (bluetooth.av_connected) {
218 bluetooth.sendMediaCommand("Next")
225 Item { Layout.fillWidth: true }
228 visible: bluetooth.connected
229 checked: bluetooth.av_connected
230 offImage: './images/AGL_MediaPlayer_Bluetooth_Inactive.svg'
231 onImage: './images/AGL_MediaPlayer_Bluetooth_Active.svg'
234 if (bluetooth.av_connected) {
235 bluetooth.disconnect_profiles()
237 bluetooth.connect_profiles()
246 Layout.fillWidth: true
247 Layout.fillHeight: true
248 Layout.preferredHeight: 407
250 PlaylistWithMetadata {
258 visible: bluetooth.av_connected == false
266 currentIndex: playlist.currentIndex
268 delegate: MouseArea {
270 width: ListView.view.width
271 height: ListView.view.height / 4
274 anchors.leftMargin: 50
275 anchors.rightMargin: 50
277 source: model.coverArt
278 fillMode: Image.PreserveAspectFit
279 Layout.preferredWidth: delegate.height
280 Layout.preferredHeight: delegate.height
283 Layout.fillWidth: true
285 Layout.fillWidth: true
289 Layout.fillWidth: true
296 text: player.time2str(model.duration)
302 playlist.currentIndex = model.index
307 highlight: Rectangle {