Merge lp:~ahayzen/music-app/fix-1482545-swipe-in-now-playing into lp:music-app

Proposed by Andrew Hayzen
Status: Needs review
Proposed branch: lp:~ahayzen/music-app/fix-1482545-swipe-in-now-playing
Merge into: lp:music-app
Prerequisite: lp:~music-app-dev/music-app/media-hub-bg-playlists-rework
Diff against target: 234 lines (+171/-26)
2 files modified
app/components/NowPlayingFullView.qml (+170/-26)
debian/changelog (+1/-0)
To merge this branch: bzr merge lp:~ahayzen/music-app/fix-1482545-swipe-in-now-playing
Reviewer Review Type Date Requested Status
Victor Thompson Needs Information
Andrew Hayzen Disapprove
Jenkins Bot continuous-integration Approve
Review via email: mp+281045@code.launchpad.net

Commit message

* Swipe left and right of album in full now playing now slide

Description of the change

* Swipe left and right of album in full now playing now slide

Note that this is broken in shuffle mode due to media-hub giving the wrong values (bug 1528072)

To post a comment you must log in.
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andrew Hayzen (ahayzen) wrote :

#blocked by bug 1528072

review: Disapprove
Revision history for this message
Victor Thompson (vthompson) wrote :

This change also isn't as nice on the desktop. Is there a way we could show the blurred bg and still support this animation?

review: Needs Information
Revision history for this message
Andrew Hayzen (ahayzen) wrote :

For the desktop I was assuming that it would have it's converged view, so haven't yet tested it on the desktop.

Unmerged revisions

914. By Andrew Hayzen

* Swipe left and right of album in full now playing now slide

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'app/components/NowPlayingFullView.qml'
--- app/components/NowPlayingFullView.qml 2015-12-21 00:42:21 +0000
+++ app/components/NowPlayingFullView.qml 2015-12-21 00:42:22 +0000
@@ -39,20 +39,185 @@
39 art: albumImage.firstSource39 art: albumImage.firstSource
40 height: parent.height - units.gu(7)40 height: parent.height - units.gu(7)
4141
42 Item {42 Row {
43 id: albumImageContainer43 id: albumImageContainer
44 anchors {44 anchors {
45 horizontalCenter: parent.horizontalCenter45 bottom: parent.bottom
46 top: parent.top46 top: parent.top
47 }47 }
48 height: parent.height48 x: -parent.width
49 width: parent.width49 width: parent.width
5050
51 Loader {
52 id: previousCoverLoader
53 anchors {
54 top: parent.top
55 }
56 asynchronous: true
57 height: parent.height
58 sourceComponent: CoverGrid {
59 id: previousCover
60 anchors {
61 fill: parent
62 }
63 size: parent.width
64
65 function setCover() {
66 covers = [newPlayer.metaForSource(newPlayer.mediaPlayer.playlist.itemSource(newPlayer.mediaPlayer.playlist.previousIndex(1)))];
67 }
68
69 Connections {
70 target: newPlayer.mediaPlayer.playlist
71 onCurrentIndexChanged: previousCover.setCover()
72 onItemInserted: previousCover.setCover()
73 onItemChanged: previousCover.setCover()
74 onItemRemoved: previousCover.setCover()
75 }
76
77 Component.onCompleted: previousCover.setCover()
78 }
79 width: parent.width
80
81 // How much of the previous cover has been shown
82 property double percentage: 1 - Math.abs(albumImageContainer.x / blurredBackground.width)
83 }
84
51 CoverGrid {85 CoverGrid {
52 id: albumImage86 id: albumImage
53 anchors.centerIn: parent87 anchors {
88 top: parent.top
89 }
54 covers: [newPlayer.currentMeta]90 covers: [newPlayer.currentMeta]
55 size: parent.height91 size: parent.width
92 }
93
94 Loader {
95 id: nextCoverLoader
96 anchors {
97 top: parent.top
98 }
99 asynchronous: true
100 height: parent.height
101 sourceComponent: CoverGrid {
102 id: nextCover
103 anchors {
104 fill: parent
105 }
106 size: parent.width
107
108 function setCover() {
109 covers = [newPlayer.metaForSource(newPlayer.mediaPlayer.playlist.itemSource(newPlayer.mediaPlayer.playlist.nextIndex(1)))];
110 }
111
112 Connections {
113 target: newPlayer.mediaPlayer.playlist
114 onCurrentIndexChanged: nextCover.setCover()
115 onItemInserted: nextCover.setCover()
116 onItemChanged: nextCover.setCover()
117 onItemRemoved: nextCover.setCover()
118 }
119
120 Component.onCompleted: nextCover.setCover()
121 }
122 width: parent.width
123
124 // How much of the next cover has been shown
125 property double percentage: Math.abs((albumImageContainer.x + blurredBackground.width) / blurredBackground.width)
126 }
127 }
128
129 MouseArea {
130 id: albumImageMouseArea
131 anchors {
132 fill: parent
133 }
134 drag.axis: Drag.XAxis
135 // Use maximum and minimum to restrict the canGoNext and canGoPrevious
136 drag.maximumX: newPlayer.mediaPlayer.playlist.canGoPrevious || animating ? 0 : -blurredBackground.width
137 drag.minimumX: newPlayer.mediaPlayer.playlist.canGoNext || animating ? -blurredBackground.width * 2 : -blurredBackground.width
138 drag.target: albumImageContainer
139
140 property bool animating: nextAnimation.running || previousAnimation.running || resetAnimation.running
141
142 onReleased: {
143 if (albumImageContainer.x < -blurredBackground.width) {
144 // Drag direction is right to left
145 // so check if has been dragged enough for activation
146
147 if (nextCoverLoader.percentage > 0.4) {
148 nextAnimation.start();
149 } else {
150 resetAnimation.start();
151 }
152 } else if (albumImageContainer.x > -blurredBackground.width) {
153 // Drag direction is left to right
154 // so check if has been dragged enough for activation
155
156 if (previousCoverLoader.percentage > 0.4) {
157 previousAnimation.start();
158 } else {
159 resetAnimation.start();
160 }
161 } else {
162 resetAnimation.start();
163 }
164 }
165
166 SequentialAnimation {
167 id: nextAnimation
168 // Move to the next cover
169 NumberAnimation {
170 duration: UbuntuAnimation.FastDuration
171 property: "x"
172 target: albumImageContainer
173 to: -blurredBackground.width * 2
174 }
175 // Pause for a few frames (3+) to let animation finish
176 // other script action causes stutter
177 NumberAnimation {
178 duration: 50
179 }
180 // Call next and jump back to the centre with the new
181 // cover to give the illusion of movement
182 ScriptAction {
183 script: {
184 newPlayer.mediaPlayer.playlist.next()
185 albumImageContainer.x = -blurredBackground.width;
186 }
187 }
188 }
189
190 SequentialAnimation {
191 id: previousAnimation
192 // Move to the previous cover
193 NumberAnimation {
194 duration: UbuntuAnimation.FastDuration
195 property: "x"
196 target: albumImageContainer
197 to: 0
198 }
199 // Pause for a few frames (3+) to let animation finish
200 // other script action causes stutter
201 NumberAnimation {
202 duration: 50
203 }
204 // Call previous and jump back to the centre with the new
205 // cover to give the illusion of movement
206 ScriptAction {
207 script: {
208 newPlayer.mediaPlayer.playlist.previous()
209 albumImageContainer.x = -blurredBackground.width;
210 }
211 }
212 }
213
214 // Animation which resets to the centre when drag is not far enough
215 NumberAnimation {
216 id: resetAnimation
217 duration: 250
218 property: "x"
219 target: albumImageContainer
220 to: -blurredBackground.width
56 }221 }
57 }222 }
58223
@@ -119,27 +284,6 @@
119 text: newPlayer.mediaPlayer.playlist.empty ? "" : newPlayer.currentMeta.author284 text: newPlayer.mediaPlayer.playlist.empty ? "" : newPlayer.currentMeta.author
120 }285 }
121 }286 }
122
123 /* Detect cover art swipe */
124 MouseArea {
125 anchors.fill: parent
126 property string direction: "None"
127 property real lastX: -1
128
129 onPressed: lastX = mouse.x
130
131 onReleased: {
132 var diff = mouse.x - lastX
133
134 if (Math.abs(diff) < units.gu(4)) {
135 return;
136 } else if (diff < 0 && newPlayer.mediaPlayer.playlist.canGoNext) {
137 newPlayer.mediaPlayer.playlist.next()
138 } else if (diff > 0 && newPlayer.mediaPlayer.playlist.canGoPrevious) {
139 newPlayer.mediaPlayer.playlist.previous()
140 }
141 }
142 }
143 }287 }
144288
145 /* Background for progress bar component */289 /* Background for progress bar component */
146290
=== modified file 'debian/changelog'
--- debian/changelog 2015-12-21 00:42:21 +0000
+++ debian/changelog 2015-12-21 00:42:22 +0000
@@ -2,6 +2,7 @@
22
3 [ Andrew Hayzen ]3 [ Andrew Hayzen ]
4 * Release 2.2ubuntu2 and start on 2.34 * Release 2.2ubuntu2 and start on 2.3
5 * Swipe left and right of album in full now playing now slide (LP: #1482545).
56
6 [ Ken VanDine ]7 [ Ken VanDine ]
7 * Install the content-hub json file in the correct place for peer registry8 * Install the content-hub json file in the correct place for peer registry

Subscribers

People subscribed via source and target branches