Merge lp:~phablet-team/music-app/final-declarative-playlist-api into lp:~music-app-dev/music-app/media-hub-bg-playlists-rework

Proposed by Andrew Hayzen
Status: Merged
Approved by: Andrew Hayzen
Approved revision: 910
Merged at revision: 892
Proposed branch: lp:~phablet-team/music-app/final-declarative-playlist-api
Merge into: lp:~music-app-dev/music-app/media-hub-bg-playlists-rework
Diff against target: 305 lines (+42/-35)
10 files modified
app/components/HeadState/MultiSelectHeadState.qml (+1/-1)
app/components/Helpers/ContentHubHelper.qml (+1/-1)
app/components/Helpers/UriHandlerHelper.qml (+1/-1)
app/components/ListItemActions/AddToQueue.qml (+1/-1)
app/components/MusicToolbar.qml (+1/-1)
app/components/NewPlayer.qml (+25/-22)
app/components/Queue.qml (+3/-3)
app/music-app.qml (+7/-3)
app/ui/NowPlaying.qml (+1/-1)
app/ui/Songs.qml (+1/-1)
To merge this branch: bzr merge lp:~phablet-team/music-app/final-declarative-playlist-api
Reviewer Review Type Date Requested Status
Andrew Hayzen Approve
Review via email: mp+277357@code.launchpad.net

Commit message

* Convert to new QDeclarativePlaylist QML API.

Description of the change

* Convert to new QDeclarativePlaylist QML API.

To post a comment you must log in.
904. By Jim Hodapp

Restore queue functionality should work again.

905. By Jim Hodapp

Debug output for restoring play queue

906. By Jim Hodapp

Debug output for storing play queue

907. By Jim Hodapp

Updated play queue saving debug statements

908. By Jim Hodapp

Make sure save queue and restore queue work

909. By Jim Hodapp

Add queue restore error message

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

1 inline comment so far....

1) This should be addSourcesFromModel (plural) ?

review: Needs Information
910. By Jim Hodapp

Fix function name.

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

LGTM, we can fix any further issues in the other branch :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/components/HeadState/MultiSelectHeadState.qml'
2--- app/components/HeadState/MultiSelectHeadState.qml 2015-11-02 15:58:44 +0000
3+++ app/components/HeadState/MultiSelectHeadState.qml 2015-11-13 13:27:56 +0000
4@@ -71,7 +71,7 @@
5 sources.push(Qt.resolvedUrl(listview.model.get(indicies[i], listview.model.RoleModelData).filename));
6 }
7
8- newPlayer.mediaPlayer.playlist.addSources(sources);
9+ newPlayer.mediaPlayer.playlist.addItems(sources);
10
11 listview.closeSelection()
12 }
13
14=== modified file 'app/components/Helpers/ContentHubHelper.qml'
15--- app/components/Helpers/ContentHubHelper.qml 2015-11-02 15:58:44 +0000
16+++ app/components/Helpers/ContentHubHelper.qml 2015-11-13 13:27:56 +0000
17@@ -225,7 +225,7 @@
18 for (i=0; i < searchPaths.length; i++) {
19 model = musicStore.lookup(decodeFileURI(searchPaths[i]))
20
21- newPlayer.mediaPlayer.playlist.addSource(Qt.resolvedUrl(decodeURIComponent(searchPaths[i])));
22+ newPlayer.mediaPlayer.playlist.addItem(Qt.resolvedUrl(decodeURIComponent(searchPaths[i])));
23 }
24
25 trackQueueClick(0);
26
27=== modified file 'app/components/Helpers/UriHandlerHelper.qml'
28--- app/components/Helpers/UriHandlerHelper.qml 2015-11-02 15:58:44 +0000
29+++ app/components/Helpers/UriHandlerHelper.qml 2015-11-13 13:27:56 +0000
30@@ -64,7 +64,7 @@
31 }
32
33 // enqueue
34- newPlayer.mediaPlayer.playlist.addSource(Qt.resolvedUrl(track.filename));
35+ newPlayer.mediaPlayer.playlist.addItem(Qt.resolvedUrl(track.filename));
36
37 // play first URI
38 if (play) {
39
40=== modified file 'app/components/ListItemActions/AddToQueue.qml'
41--- app/components/ListItemActions/AddToQueue.qml 2015-11-02 15:58:44 +0000
42+++ app/components/ListItemActions/AddToQueue.qml 2015-11-13 13:27:56 +0000
43@@ -29,6 +29,6 @@
44
45 onTriggered: {
46 console.debug("Debug: Add track to queue: " + model)
47- newPlayer.mediaPlayer.playlist.addSource(Qt.resolvedUrl(model.filename))
48+ newPlayer.mediaPlayer.playlist.addItem(Qt.resolvedUrl(model.filename))
49 }
50 }
51
52=== modified file 'app/components/MusicToolbar.qml'
53--- app/components/MusicToolbar.qml 2015-11-02 15:58:44 +0000
54+++ app/components/MusicToolbar.qml 2015-11-13 13:27:56 +0000
55@@ -170,7 +170,7 @@
56 fontSize: "small"
57 font.weight: Font.DemiBold
58 text: newPlayer.currentMeta.title === ""
59- ? newPlayer.mediaPlayer.playlist.currentSource
60+ ? newPlayer.mediaPlayer.playlist.currentItemSource
61 : newPlayer.currentMeta.title
62 }
63
64
65=== modified file 'app/components/NewPlayer.qml'
66--- app/components/NewPlayer.qml 2015-11-02 17:10:45 +0000
67+++ app/components/NewPlayer.qml 2015-11-13 13:27:56 +0000
68@@ -26,7 +26,7 @@
69 Item {
70 objectName: "player"
71
72- property alias count: mediaPlayerPlaylist.mediaCount
73+ property alias count: mediaPlayerPlaylist.itemCount
74 property var currentMeta: ({})
75 property alias mediaPlayer: mediaPlayer
76 property alias repeat: settings.repeat
77@@ -73,21 +73,22 @@
78 }
79 }
80
81- readonly property int count: mediaCount // header actions etc depend on the model having 'count'
82+ readonly property int count: itemCount // header actions etc depend on the model having 'count'
83 property int pendingCurrentIndex: -1
84 property var pendingCurrentState: null
85 property int pendingShuffle: -1
86
87- onCurrentSourceChanged: currentMeta = metaForSource(currentSource)
88- onMediaChanged: {
89+ onCurrentItemSourceChanged: currentMeta = metaForSource(currentItemSource)
90+ onItemChanged: {
91+ console.debug("*** Saving play queue in onItemChanged");
92 saveQueue()
93
94- // FIXME: shouldn't be needed? seems to be a bug where when appending currentSourceChanged is not emitted
95+ // FIXME: shouldn't be needed? seems to be a bug where when appending currentItemChanged is not emitted
96 //if (start === currentIndex) {
97 // currentMeta = metaForSource(currentSource)
98 //}
99 }
100- onMediaInserted: {
101+ onItemInserted: {
102 // When add to queue is done on an empty list currentIndex needs to be set
103 if (start === 0 && currentIndex === -1 && pendingCurrentIndex < 1 && pendingShuffle === -1) {
104 currentIndex = 0;
105@@ -97,7 +98,7 @@
106 }
107
108 // Check if the pendingCurrentIndex is now valid
109- if (pendingCurrentIndex !== -1 && pendingCurrentIndex < mediaCount) {
110+ if (pendingCurrentIndex !== -1 && pendingCurrentIndex < itemCount) {
111 currentIndex = pendingCurrentIndex;
112
113 pendingCurrentIndex = -1;
114@@ -106,26 +107,28 @@
115
116 // Check if there is pending shuffle
117 // pendingShuffle holds the expected size of the model
118- if (pendingShuffle > -1 && pendingShuffle <= mediaCount) {
119+ if (pendingShuffle > -1 && pendingShuffle <= itemCount) {
120 mediaPlayerPlaylist.shuffle();
121
122 pendingShuffle = -1;
123 mediaPlayer.next(); // play a random track
124 }
125
126+ console.debug("*** Saving play queue in onItemInserted");
127 saveQueue()
128
129- // FIXME: shouldn't be needed? seems to be a bug where when appending currentSourceChanged is not emitted
130+ // FIXME: shouldn't be needed? seems to be a bug where when appending currentItemChanged is not emitted
131 if (start === currentIndex) {
132- currentMeta = metaForSource(currentSource)
133+ currentMeta = metaForSource(currentItemSource)
134 }
135 }
136- onMediaRemoved: {
137+ onItemRemoved: {
138+ console.debug("*** Saving play queue in onItemRemoved");
139 saveQueue()
140
141- // FIXME: shouldn't be needed? seems to be a bug where when appending currentSourceChanged is not emitted
142+ // FIXME: shouldn't be needed? seems to be a bug where when appending currentItemChanged is not emitted
143 if (start === currentIndex) {
144- currentMeta = metaForSource(currentSource)
145+ currentMeta = metaForSource(currentItemSource)
146 }
147 }
148
149@@ -138,7 +141,7 @@
150 sources.push(Qt.resolvedUrl(model.get(i, model.RoleModelData).filename));
151 }
152
153- addSources(sources);
154+ addItems(sources);
155 }
156
157 function processPendingCurrentState() {
158@@ -158,11 +161,11 @@
159 pendingCurrentState = null;
160 }
161
162- function removeSources(items) {
163+ function removeItems(items) {
164 items.sort();
165
166 for (var i=0; i < items.length; i++) {
167- removeSource(items[i] - i);
168+ removeItem(items[i] - i);
169 }
170 }
171
172@@ -178,8 +181,8 @@
173
174 var sources = [];
175
176- for (var i=0; i < mediaPlayerPlaylist.mediaCount; i++) {
177- sources.push(mediaPlayerPlaylist.source(i));
178+ for (var i=0; i < mediaPlayerPlaylist.itemCount; i++) {
179+ sources.push(mediaPlayerPlaylist.itemSource(i));
180 }
181
182 if (sources.length > 0) {
183@@ -189,8 +192,8 @@
184 }
185
186 function setCurrentIndex(index) {
187- // Set the currentIndex but if the mediaCount is too low then wait
188- if (index < mediaPlayerPlaylist.mediaCount) {
189+ // Set the currentIndex but if the itemCount is too low then wait
190+ if (index < mediaPlayerPlaylist.itemCount) {
191 mediaPlayerPlaylist.currentIndex = index;
192 } else {
193 pendingCurrentIndex = index;
194@@ -208,7 +211,7 @@
195
196 function setPendingShuffle(modelSize) {
197 // Run shuffle() when the modelSize is reached
198- if (modelSize <= mediaCount) {
199+ if (modelSize <= itemCount) {
200 mediaPlayerPlaylist.shuffle();
201 mediaPlayer.next();
202 } else {
203@@ -225,7 +228,7 @@
204 settings.shuffle
205 }
206 property bool canGoNext: {
207- playlist.currentIndex !== (playlist.mediaCount - 1) ||
208+ playlist.currentIndex !== (playlist.itemCount - 1) ||
209 settings.repeat ||
210 settings.shuffle
211 }
212
213=== modified file 'app/components/Queue.qml'
214--- app/components/Queue.qml 2015-11-03 19:36:24 +0000
215+++ app/components/Queue.qml 2015-11-13 13:27:56 +0000
216@@ -65,14 +65,14 @@
217 leadingActions: ListItemActions {
218 actions: [
219 Remove {
220- onTriggered: newPlayer.mediaPlayer.playlist.removeSource(index)
221+ onTriggered: newPlayer.mediaPlayer.playlist.removeItem(index)
222 }
223 ]
224 }
225 multiselectable: true
226 objectName: "nowPlayingListItem" + index
227 state: ""
228- reorderable: true // FIXME: needs testing, sort out reordering we need moveSource(from, to);
229+ reorderable: true // FIXME: needs testing, sort out reordering we need moveItem(from, to);
230 trailingActions: ListItemActions {
231 actions: [
232 AddToPlaylist {
233@@ -93,6 +93,6 @@
234 onReorder: {
235 console.debug("Move: ", from, to);
236
237- newPlayer.mediaPlayer.playlist.moveSource(from, to);
238+ newPlayer.mediaPlayer.playlist.moveItem(from, to);
239 }
240 }
241
242=== modified file 'app/music-app.qml'
243--- app/music-app.qml 2015-11-02 15:58:44 +0000
244+++ app/music-app.qml 2015-11-13 13:27:56 +0000
245@@ -240,11 +240,15 @@
246
247 // FIXME: using old queueList for now, move to load()/save() long term
248 if (!Library.isQueueEmpty()) {
249- newPlayer.mediaPlayer.playlist.addSources(Library.getQueue());
250+ console.debug("*** Restoring library queue");
251+ newPlayer.mediaPlayer.playlist.addItems(Library.getQueue());
252
253 newPlayer.mediaPlayer.playlist.setCurrentIndex(queueIndex);
254 newPlayer.mediaPlayer.playlist.setPendingCurrentState(MediaPlayer.PausedState); // TODO: confirm this works if index changes after
255 }
256+ else {
257+ console.debug("Queue is empty, not loading any recent tracks");
258+ }
259 }
260
261 // everything else
262@@ -350,7 +354,7 @@
263 if (!clear) { // FIXME: is this even used anymore? trackQueueClick instead?
264 // If same track and on Now playing page then toggle
265 if ((mainPageStack.currentPage.title === i18n.tr("Now playing") || mainPageStack.currentPage.title === i18n.tr("Queue"))
266- && Qt.resolvedUrl(newPlayer.mediaPlayer.playlist.currentSource) === file) {
267+ && Qt.resolvedUrl(newPlayer.mediaPlayer.playlist.currentItemSource) === file) {
268 newPlayer.mediaPlayer.toggle()
269 return;
270 }
271@@ -440,7 +444,7 @@
272 // If there are removed tracks then remove them from the queue and store
273 if (removed.length > 0) {
274 console.debug("Removed queue:", JSON.stringify(removed))
275- newPlayer.mediaPlayer.playlist.removeSources(removed.slice());
276+ newPlayer.mediaPlayer.playlist.removeItems(removed.slice());
277 }
278
279 // Loop through playlists, getPlaylistTracks will remove any tracks that don't exist
280
281=== modified file 'app/ui/NowPlaying.qml'
282--- app/ui/NowPlaying.qml 2015-11-02 17:10:45 +0000
283+++ app/ui/NowPlaying.qml 2015-11-13 13:27:56 +0000
284@@ -131,7 +131,7 @@
285 // Use slice() to copy the list
286 // so that the indexes don't change as they are removed
287 // TODO: test!
288- newPlayer.mediaPlayer.playlist.removeSources(selectedIndices.slice());
289+ newPlayer.mediaPlayer.playlist.removeItems(selectedIndices.slice());
290 }
291 }
292 ]
293
294=== modified file 'app/ui/Songs.qml'
295--- app/ui/Songs.qml 2015-11-02 15:58:44 +0000
296+++ app/ui/Songs.qml 2015-11-13 13:27:56 +0000
297@@ -118,7 +118,7 @@
298 onItemClicked: {
299 if (songsPage.state === "search") { // only play single track when searching
300 newPlayer.mediaPlayer.playlist.clear();
301- newPlayer.mediaPlayer.playlist.addSource(Qt.resolvedUrl(songsModelFilter.get(index).filename));
302+ newPlayer.mediaPlayer.playlist.addItem(Qt.resolvedUrl(songsModelFilter.get(index).filename));
303 trackQueueClick(0)
304 } else {
305 trackClicked(songsModelFilter, index) // play track

Subscribers

People subscribed via source and target branches