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
29 audioRole: MediaPlayer.MusicRole
32 function time2str(value) {
33 return Qt.formatTime(new Date(value), 'mm:ss')
35 onPositionChanged: slider.value = player.position
40 playbackMode: random.checked ? Playlist.Random : loop.checked ? Playlist.Loop : Playlist.Sequential
42 Component.onCompleted: {
43 playlist.addItems(mediaFiles)
51 Layout.fillWidth: true
52 Layout.fillHeight: true
53 Layout.preferredHeight: 1080
56 anchors.left: parent.left
57 anchors.right: parent.right
58 anchors.bottom: parent.bottom
59 height: sourceSize.height * width / sourceSize.width
60 fillMode: Image.PreserveAspectCrop
61 source: player.metaData.coverArtImage ? player.metaData.coverArtImage : ''
65 anchors.left: parent.left
66 anchors.right: parent.right
67 anchors.bottom: parent.bottom
77 anchors.margins: root.width * 0.02
79 Layout.fillWidth: true
80 Layout.fillHeight: true
85 offImage: './images/AGL_MediaPlayer_Shuffle_Inactive.svg'
86 onImage: './images/AGL_MediaPlayer_Shuffle_Active.svg'
90 offImage: './images/AGL_MediaPlayer_Loop_Inactive.svg'
91 onImage: './images/AGL_MediaPlayer_Loop_Active.svg'
98 Layout.alignment: Layout.Center
99 text: player.metaData.title ? player.metaData.title : ''
100 horizontalAlignment: Label.AlignHCenter
101 verticalAlignment: Label.AlignVCenter
105 Layout.alignment: Layout.Center
106 text: player.metaData.author ? player.metaData.author : ''
107 horizontalAlignment: Label.AlignHCenter
108 verticalAlignment: Label.AlignVCenter
109 font.pixelSize: title.font.pixelSize * 0.6
115 Layout.fillWidth: true
119 anchors.left: parent.left
120 anchors.bottom: parent.top
122 text: player.time2str(player.position)
126 anchors.right: parent.right
127 anchors.bottom: parent.top
129 text: player.time2str(player.duration)
131 onPressedChanged: player.seek(value)
134 Layout.fillHeight: true
136 // source: './images/AGL_MediaPlayer_Playlist_Inactive.svg'
139 // source: './images/AGL_MediaPlayer_CD_Inactive.svg'
141 Item { Layout.fillWidth: true }
143 offImage: './images/AGL_MediaPlayer_BackArrow.svg'
144 onClicked: playlist.previous()
148 offImage: './images/AGL_MediaPlayer_Player_Play.svg'
149 onClicked: player.play()
152 when: player.playbackState === MediaPlayer.PlayingState
155 offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
156 onClicked: player.pause()
162 offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
163 onClicked: playlist.next()
166 Item { Layout.fillWidth: true }
168 // source: './images/AGL_MediaPlayer_Bluetooth_Inactive.svg'
171 // source: './images/AGL_MediaPlayer_Radio_Inactive.svg'
178 Layout.fillWidth: true
179 Layout.fillHeight: true
180 Layout.preferredHeight: 407
189 model: PlaylistWithMetadata {
192 currentIndex: playlist.currentIndex
194 delegate: MouseArea {
196 width: ListView.view.width
197 height: ListView.view.height / 4
200 anchors.leftMargin: 50
201 anchors.rightMargin: 50
203 source: model.coverArt
204 fillMode: Image.PreserveAspectFit
205 Layout.preferredWidth: delegate.height
206 Layout.preferredHeight: delegate.height
209 Layout.fillWidth: true
211 Layout.fillWidth: true
215 Layout.fillWidth: true
222 text: player.time2str(model.duration)
228 playlist.currentIndex = model.index
233 highlight: Rectangle {