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
36 Component.onCompleted: console.debug('player.supportedAudioRoles()', player.supportedAudioRoles())
41 playbackMode: random.checked ? Playlist.Random : loop.checked ? Playlist.Loop : Playlist.Sequential
43 Component.onCompleted: {
44 playlist.addItems(mediaFiles)
52 Layout.fillWidth: true
53 Layout.fillHeight: true
54 Layout.preferredHeight: 3
57 anchors.left: parent.left
58 anchors.right: parent.right
59 anchors.bottom: parent.bottom
60 height: sourceSize.height * width / sourceSize.width
61 fillMode: Image.PreserveAspectCrop
62 source: player.metaData.coverArtImage ? player.metaData.coverArtImage : ''
66 anchors.left: parent.left
67 anchors.right: parent.right
68 anchors.bottom: parent.bottom
78 anchors.margins: root.width * 0.02
80 Layout.fillWidth: true
81 Layout.fillHeight: true
86 offImage: './images/AGL_MediaPlayer_Shuffle_Inactive.svg'
87 onImage: './images/AGL_MediaPlayer_Shuffle_Active.svg'
91 offImage: './images/AGL_MediaPlayer_Loop_Inactive.svg'
92 onImage: './images/AGL_MediaPlayer_Loop_Active.svg'
99 Layout.alignment: Layout.Center
100 text: player.metaData.title ? player.metaData.title : ''
101 horizontalAlignment: Label.AlignHCenter
102 verticalAlignment: Label.AlignVCenter
106 Layout.alignment: Layout.Center
107 text: player.metaData.author ? player.metaData.author : ''
108 horizontalAlignment: Label.AlignHCenter
109 verticalAlignment: Label.AlignVCenter
110 font.pixelSize: title.font.pixelSize * 0.6
116 Layout.fillWidth: true
120 anchors.left: parent.left
121 anchors.bottom: parent.top
123 text: player.time2str(player.position)
127 anchors.right: parent.right
128 anchors.bottom: parent.top
130 text: player.time2str(player.duration)
132 onPressedChanged: player.seek(value)
135 Layout.fillHeight: true
137 // source: './images/AGL_MediaPlayer_Playlist_Inactive.svg'
140 // source: './images/AGL_MediaPlayer_CD_Inactive.svg'
142 Item { Layout.fillWidth: true }
144 offImage: './images/AGL_MediaPlayer_BackArrow.svg'
145 onClicked: playlist.previous()
149 offImage: './images/AGL_MediaPlayer_Player_Play.svg'
150 onClicked: player.play()
153 when: player.playbackState === MediaPlayer.PlayingState
156 offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
157 onClicked: player.pause()
163 offImage: './images/AGL_MediaPlayer_ForwardArrow.svg'
164 onClicked: playlist.next()
167 Item { Layout.fillWidth: true }
169 // source: './images/AGL_MediaPlayer_Bluetooth_Inactive.svg'
172 // source: './images/AGL_MediaPlayer_Radio_Inactive.svg'
179 Layout.fillWidth: true
180 Layout.fillHeight: true
181 Layout.preferredHeight: 2
190 model: PlaylistWithMetadata {
193 currentIndex: playlist.currentIndex
195 delegate: MouseArea {
197 width: ListView.view.width
198 height: ListView.view.height / 4
201 anchors.leftMargin: 50
202 anchors.rightMargin: 50
204 source: model.coverArt
205 fillMode: Image.PreserveAspectFit
206 Layout.preferredWidth: delegate.height
207 Layout.preferredHeight: delegate.height
210 Layout.fillWidth: true
212 Layout.fillWidth: true
216 Layout.fillWidth: true
223 text: player.time2str(model.duration)
229 playlist.currentIndex = model.index
234 highlight: Rectangle {