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
27 function clearMetadata() {
30 duration.text = player.time2str(0)
31 albumart.visible = false
36 onProcessPlaylistUpdate: {
38 playlist.addItems(mediaFiles)
40 playlistmodel.setSource(playlist)
41 playlistview.visible = true
42 albumart.visible = true
45 onProcessPlaylistHide: {
47 playlistview.visible = false
55 audioRole: MediaPlayer.MusicRole
58 function time2str(value) {
59 return Qt.formatTime(new Date(value), 'mm:ss')
61 onPositionChanged: slider.value = player.position
66 playbackMode: random.checked ? Playlist.Random : loop.checked ? Playlist.Loop : Playlist.Sequential
68 Component.onCompleted: {
69 playlist.addItems(mediaFiles)
77 Layout.fillWidth: true
78 Layout.fillHeight: true
79 Layout.preferredHeight: 1080
83 anchors.left: parent.left
84 anchors.right: parent.right
85 anchors.bottom: parent.bottom
86 height: sourceSize.height * width / sourceSize.width
87 fillMode: Image.PreserveAspectCrop
88 source: player.metaData.coverArtImage ? player.metaData.coverArtImage : ''
92 anchors.left: parent.left
93 anchors.right: parent.right
94 anchors.bottom: parent.bottom
104 anchors.margins: root.width * 0.02
106 Layout.fillWidth: true
107 Layout.fillHeight: true
112 offImage: './images/AGL_MediaPlayer_Shuffle_Inactive.svg'
113 onImage: './images/AGL_MediaPlayer_Shuffle_Active.svg'
117 offImage: './images/AGL_MediaPlayer_Loop_Inactive.svg'
118 onImage: './images/AGL_MediaPlayer_Loop_Active.svg'
125 Layout.alignment: Layout.Center
126 text: player.metaData.title ? player.metaData.title : ''
127 horizontalAlignment: Label.AlignHCenter
128 verticalAlignment: Label.AlignVCenter
132 Layout.alignment: Layout.Center
133 text: player.metaData.contributingArtist ? player.metaData.contributingArtist : ''
134 horizontalAlignment: Label.AlignHCenter
135 verticalAlignment: Label.AlignVCenter
136 font.pixelSize: title.font.pixelSize * 0.6
142 Layout.fillWidth: true
146 anchors.left: parent.left
147 anchors.bottom: parent.top
149 text: player.time2str(player.position)
153 anchors.right: parent.right
154 anchors.bottom: parent.top
156 text: player.time2str(player.duration)
158 onPressedChanged: player.seek(value)
161 Layout.fillHeight: true
163 // source: './images/AGL_MediaPlayer_Playlist_Inactive.svg'
166 // source: './images/AGL_MediaPlayer_CD_Inactive.svg'
168 Item { Layout.fillWidth: true }
170 offImage: './images/AGL_MediaPlayer_BackArrow.svg'
171 onClicked: playlist.previous()
175 offImage: './images/AGL_MediaPlayer_Player_Play.svg'
176 onClicked: player.play()
179 when: player.playbackState === MediaPlayer.PlayingState
182 offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
183 onClicked: player.pause()
189 offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
190 onClicked: playlist.next()
193 Item { Layout.fillWidth: true }
195 // source: './images/AGL_MediaPlayer_Bluetooth_Inactive.svg'
198 // source: './images/AGL_MediaPlayer_Radio_Inactive.svg'
205 Layout.fillWidth: true
206 Layout.fillHeight: true
207 Layout.preferredHeight: 407
209 PlaylistWithMetadata {
224 currentIndex: playlist.currentIndex
226 delegate: MouseArea {
228 width: ListView.view.width
229 height: ListView.view.height / 4
232 anchors.leftMargin: 50
233 anchors.rightMargin: 50
235 source: model.coverArt
236 fillMode: Image.PreserveAspectFit
237 Layout.preferredWidth: delegate.height
238 Layout.preferredHeight: delegate.height
241 Layout.fillWidth: true
243 Layout.fillWidth: true
247 Layout.fillWidth: true
254 text: player.time2str(model.duration)
260 playlist.currentIndex = model.index
265 highlight: Rectangle {