@@ -52,154 +52,174 @@ GenericPreview {
52 Component {
52 Component {
53 id: descriptionComponent
53 id: descriptionComponent
56 height: childrenRect.height
56 height: childrenRect.height
59+ objectName: "audioPlayer"
60+ property real percent: audioPlayer.position * 100 / audioPlayer.duration
64+ Component.onDestruction: {
68+ onErrorStringChanged: print("Audio player error:", errorString)
59− objectName: "topDivider"
71+ Connections {
73+ onIsCurrentChanged: {
74+ if (!root.isCurrent) {
61 left: parent.left
82 left: parent.left
62 right: parent.right
83 right: parent.right
64− visible: trackRepeater.count > 0
67− Repeater {
86+ height: childrenRect.height
69− objectName: "trackRepeater"
89+ objectName: "topDivider"
94+ visible: trackRepeater.count > 0
71− model: previewData.tracks
97+ Repeater {
99+ objectName: "trackRepeater"
73− signal stopPlayback()
101+ model: previewData.tracks
75− delegate: Item {
103+ delegate: Item {
76− objectName: "trackItem" + index
105+ objectName: "trackItem" + index
81 width: parent.width
106 width: parent.width
82− spacing: units.gu(1)
107+ height: units.gu(5)
83− property int column1Width: units.gu(3)
108+ property bool isPlayingItem: false
84− property int column2Width: width - (2 * spacing) - column1Width - column3Width
109+
85− property int column3Width: units.gu(4)
110+ Connections {
86− anchors.verticalCenter: parent.verticalCenter
111+ target: audioPlayer
87−
112+ onUriChanged: trackItem.isPlayingItem = false;
90− objectName: "playButton"
91− width: trackRow.column1Width
96− anchors.centerIn: playButtonShape
97− name: audioPlayer.playbackState == Audio.PlayingState ? "media-playback-pause" : "media-playback-start"
102− anchors.fill: parent
104− if (audioPlayer.playbackState == Audio.PlayingState) {
105− audioPlayer.pause();
106− } else if (audioPlayer.playbackState == Audio.PausedState){
109− trackRepeater.stopPlayback();
116− Label {
115+ function play() {
117− objectName: "trackTitleLabel"
116+ audioPlayer.stop();
118− fontSize: "small"
117+ audioPlayer.uri = "";
119− opacity: 0.9
118+ audioPlayer.uri = model.uri;
120− color: "white"
119+ isPlayingItem = true;
121− horizontalAlignment: Text.AlignLeft
120+ audioPlayer.play();
126+ spacing: units.gu(1)
127+ property int column1Width: units.gu(3)
128+ property int column2Width: width - (2 * spacing) - column1Width - column3Width
129+ property int column3Width: units.gu(4)
122 anchors.verticalCenter: parent.verticalCenter
130 anchors.verticalCenter: parent.verticalCenter
123− width: parent.column2Width
127− elide: Text.ElideRight
129 UbuntuShape {
132 UbuntuShape {
130− id: progressBarFill
133+ id: playButtonShape
131− objectName: "progressBarFill"
134+ objectName: "playButton"
132− color: UbuntuColors.orange
135+ width: trackRow.column1Width
133− anchors.left: progressBarImage.left
136+ height: width
134− anchors.right: progressBarImage.right
137+ Icon {
135− anchors.verticalCenter: progressBarImage.verticalCenter
138+ width: units.gu(2)
136− height: units.dp(2)
139+ height: width
137− anchors.margins: units.dp(2)
140+ anchors.centerIn: playButtonShape
138− anchors.rightMargin: maxWidth - (maxWidth * audioPlayer.percent / 100) + units.dp(2)
141+ name: audioPlayer.playbackState == Audio.PlayingState && trackItem.isPlayingItem ? "media-playback-pause" : "media-playback-start"
139− visible: progressBarImage.visible
142+ color: "white"
140− property int maxWidth: progressBarImage.width - units.dp(4)
143+ opacity: .9
146+ anchors.fill: parent
148+ if (trackItem.isPlayingItem) {
149+ if (audioPlayer.playbackState == Audio.PlayingState) {
150+ audioPlayer.pause();
151+ } else if (audioPlayer.playbackState == Audio.PausedState){
142− Image {
154+ } else {
143− id: progressBarImage
155+ trackItem.play();
145− left: parent.left
157+ }
150− visible: audioPlayer.playbackState != Audio.StoppedState
151− source: "graphics/music_progress_bg.png"
157− objectName: "timeLabel"
161− anchors.verticalCenter: parent.verticalCenter
162− horizontalAlignment: Text.AlignRight
163− width: parent.column3Width
173− bottom: parent.bottom
179− id: audioPlayer
162+ objectName: "trackTitleLabel"
180− objectName: "audioPlayer"
163+ fontSize: "small"
181− source: uri
164+ opacity: 0.9
182− property real percent: audioPlayer.position * 100 / audioPlayer.duration
165+ color: "white"
166+ horizontalAlignment: Text.AlignLeft
167+ anchors.verticalCenter: parent.verticalCenter
168+ width: parent.column2Width
172+ elide: Text.ElideRight
176+ objectName: "progressBarFill"
177+ color: UbuntuColors.orange
178+ anchors.left: progressBarImage.left
179+ anchors.right: progressBarImage.right
180+ anchors.verticalCenter: progressBarImage.verticalCenter
182+ anchors.margins: units.dp(2)
183+ anchors.rightMargin: maxWidth - (maxWidth * audioPlayer.percent / 100) + units.dp(2)
184+ visible: progressBarImage.visible
185+ property int maxWidth: progressBarImage.width - units.dp(4)
188+ id: progressBarImage
195+ visible: audioPlayer.playbackState != Audio.StoppedState && trackItem.isPlayingItem
196+ source: "graphics/music_progress_bg.png"
184− Component.onDestruction: {
198+ }
185− audioPlayer.stop();
199+ }
202+ objectName: "timeLabel"
206+ anchors.verticalCenter: parent.verticalCenter
207+ horizontalAlignment: Text.AlignRight
208+ width: parent.column3Width
188− onErrorStringChanged: print("Audio player error:", errorString)
215+ ThinDivider {
190− }
217+ left: parent.left
191− Connections {
218+ bottom: parent.bottom
192− target: root
219+ right: parent.right
193− onIsCurrentChanged: {
194− if (!root.isCurrent) {
200− target: trackRepeater
201− onStopPlayback: audioPlayer.stop();