Merge lp:~ahayzen/music-app/remix-async-load-songs-albums-player into lp:music-app/remix

Proposed by Andrew Hayzen
Status: Rejected
Rejected by: Andrew Hayzen
Proposed branch: lp:~ahayzen/music-app/remix-async-load-songs-albums-player
Merge into: lp:music-app/remix
Diff against target: 535 lines (+203/-120)
13 files modified
MusicAlbums.qml (+15/-7)
MusicArtists.qml (+11/-3)
MusicGenres.qml (+14/-7)
MusicNowPlaying.qml (+16/-4)
MusicPlaylists.qml (+16/-6)
MusicStart.qml (+17/-10)
MusicTracks.qml (+8/-2)
MusicaddtoPlaylist.qml (+2/-0)
Player.qml (+72/-56)
common/AlbumsPage.qml (+14/-7)
common/ListItemActions/AddToPlaylist.qml (+9/-2)
common/SongsPage.qml (+8/-2)
music-app.qml (+1/-14)
To merge this branch: bzr merge lp:~ahayzen/music-app/remix-async-load-songs-albums-player
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Needs Fixing
Victor Thompson Needs Fixing
Review via email: mp+239506@code.launchpad.net

Commit message

* Async load AlbumsPage.qml SongsPage.qml
* Async load MediaPlayer object

Description of the change

* Async load AlbumsPage.qml SongsPage.qml
* Async load MediaPlayer object

This reduces the startup time from ~6s -> ~5.5s

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Victor Thompson (vthompson) wrote :

When removing a playlist the application becomes unresponsive and the following error is produced:

QQmlExpression: Attempted to evaluate an expression in an invalid context

review: Needs Fixing
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

702. By Andrew Hayzen

* Workaround for freezing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'MusicAlbums.qml'
2--- MusicAlbums.qml 2014-10-12 16:42:07 +0000
3+++ MusicAlbums.qml 2014-10-23 22:16:21 +0000
4@@ -48,13 +48,21 @@
5 secondaryText: model.artist
6
7 onClicked: {
8- songsPage.album = model.title;
9- songsPage.covers = [{art: model.art}]
10- songsPage.genre = undefined
11- songsPage.isAlbum = true
12- songsPage.line1 = model.artist
13- songsPage.line2 = model.title
14- songsPage.title = i18n.tr("Album")
15+ var comp = Qt.createComponent("common/SongsPage.qml")
16+ var songsPage = comp.createObject(mainPageStack,
17+ {
18+ "album": model.title,
19+ "covers": [{art: model.art}],
20+ "isAlbum": true,
21+ "genre": undefined,
22+ "title": i18n.tr("Album"),
23+ "line1": model.artist,
24+ "line2": model.title,
25+ });
26+
27+ if (songsPage === null) { // Error Handling
28+ console.log("Error creating object");
29+ }
30
31 mainPageStack.push(songsPage)
32 }
33
34=== modified file 'MusicArtists.qml'
35--- MusicArtists.qml 2014-10-22 16:03:45 +0000
36+++ MusicArtists.qml 2014-10-23 22:16:21 +0000
37@@ -72,9 +72,17 @@
38
39
40 onClicked: {
41- albumsPage.artist = model.artist;
42- albumsPage.covers = artistCard.coverSources
43- albumsPage.title = i18n.tr("Artist")
44+ var comp = Qt.createComponent("common/AlbumsPage.qml")
45+ var albumsPage = comp.createObject(mainPageStack,
46+ {
47+ "artist": model.artist,
48+ "covers": artistCard.coverSources,
49+ "title": i18n.tr("Artist"),
50+ });
51+
52+ if (albumsPage === null) { // Error Handling
53+ console.log("Error creating object");
54+ }
55
56 mainPageStack.push(albumsPage)
57 }
58
59=== modified file 'MusicGenres.qml'
60--- MusicGenres.qml 2014-10-21 15:09:13 +0000
61+++ MusicGenres.qml 2014-10-23 22:16:21 +0000
62@@ -82,14 +82,21 @@
63 }
64
65 onClicked: {
66- songsPage.covers = genreCard.coverSources
67- songsPage.album = undefined
68- songsPage.isAlbum = true
69- songsPage.genre = model.genre;
70- songsPage.title = i18n.tr("Genre")
71- songsPage.line2 = model.genre
72- songsPage.line1 = i18n.tr("Genre")
73+ var comp = Qt.createComponent("common/SongsPage.qml")
74+ var songsPage = comp.createObject(mainPageStack,
75+ {
76+ "covers": genreCard.coverSources,
77+ "album": undefined,
78+ "isAlbum": true,
79+ "genre": model.genre,
80+ "title": i18n.tr("Genre"),
81+ "line2": model.genre,
82+ "line1": i18n.tr("Genre")
83+ });
84
85+ if (songsPage === null) { // Error Handling
86+ console.log("Error creating object");
87+ }
88
89 mainPageStack.push(songsPage)
90 }
91
92=== modified file 'MusicNowPlaying.qml'
93--- MusicNowPlaying.qml 2014-10-22 22:39:03 +0000
94+++ MusicNowPlaying.qml 2014-10-23 22:16:21 +0000
95@@ -82,8 +82,14 @@
96 items.push(makeDict(trackQueue.model.get(i)));
97 }
98
99- chosenElements = items;
100- mainPageStack.push(addtoPlaylist)
101+ var comp = Qt.createComponent("MusicaddtoPlaylist.qml")
102+ var addToPlaylist = comp.createObject(mainPageStack, {"chosenElements": items});
103+
104+ if (addToPlaylist === null) { // Error Handling
105+ console.log("Error creating object");
106+ }
107+
108+ mainPageStack.push(addToPlaylist)
109 }
110 },
111 Action {
112@@ -136,8 +142,14 @@
113 items.push(makeDict(trackQueue.model.get(queuelist.selectedItems[i])));
114 }
115
116- chosenElements = items;
117- mainPageStack.push(addtoPlaylist)
118+ var comp = Qt.createComponent("MusicaddtoPlaylist.qml")
119+ var addToPlaylist = comp.createObject(mainPageStack, {"chosenElements": items});
120+
121+ if (addToPlaylist === null) { // Error Handling
122+ console.log("Error creating object");
123+ }
124+
125+ mainPageStack.push(addToPlaylist)
126
127 queuelist.closeSelection()
128 }
129
130=== modified file 'MusicPlaylists.qml'
131--- MusicPlaylists.qml 2014-10-13 16:56:55 +0000
132+++ MusicPlaylists.qml 2014-10-23 22:16:21 +0000
133@@ -62,12 +62,22 @@
134
135 onClicked: {
136 albumTracksModel.filterPlaylistTracks(name)
137- songsPage.isAlbum = false
138- songsPage.line1 = i18n.tr("Playlist")
139- songsPage.line2 = model.name
140- songsPage.covers = coverSources
141- songsPage.genre = undefined
142- songsPage.title = i18n.tr("Playlist")
143+
144+ var comp = Qt.createComponent("common/SongsPage.qml")
145+ var songsPage = comp.createObject(mainPageStack,
146+ {
147+ "album": undefined,
148+ "covers": coverSources,
149+ "isAlbum": false,
150+ "genre": undefined,
151+ "title": i18n.tr("Playlist"),
152+ "line1": i18n.tr("Playlist"),
153+ "line2": model.name,
154+ });
155+
156+ if (songsPage === null) { // Error Handling
157+ console.log("Error creating object");
158+ }
159
160 mainPageStack.push(songsPage)
161 }
162
163=== modified file 'MusicStart.qml'
164--- MusicStart.qml 2014-10-22 16:03:45 +0000
165+++ MusicStart.qml 2014-10-23 22:16:21 +0000
166@@ -59,16 +59,23 @@
167 onClicked: {
168 if (type === "playlist") {
169 albumTracksModel.filterPlaylistTracks(model.key)
170- } else {
171- songsPage.album = title;
172- }
173- songsPage.genre = undefined;
174-
175- songsPage.line1 = secondaryText
176- songsPage.line2 = primaryText
177- songsPage.covers = coverSources
178- songsPage.isAlbum = (type === "album")
179- songsPage.title = songsPage.isAlbum ? i18n.tr("Album") : i18n.tr("Playlist")
180+ }
181+
182+ var comp = Qt.createComponent("common/SongsPage.qml")
183+ var songsPage = comp.createObject(mainPageStack,
184+ {
185+ "album": type !== "playlist" ? title : undefined,
186+ "covers": coverSources,
187+ "isAlbum": (type === "album"),
188+ "genre": undefined,
189+ "title": (type === "album") ? i18n.tr("Album") : i18n.tr("Playlist"),
190+ "line1": secondaryText,
191+ "line2": primaryText,
192+ });
193+
194+ if (songsPage === null) { // Error Handling
195+ console.log("Error creating object");
196+ }
197
198 mainPageStack.push(songsPage)
199 }
200
201=== modified file 'MusicTracks.qml'
202--- MusicTracks.qml 2014-10-22 22:39:03 +0000
203+++ MusicTracks.qml 2014-10-23 22:16:21 +0000
204@@ -66,8 +66,14 @@
205 items.push(makeDict(tracklist.model.get(tracklist.selectedItems[i], tracklist.model.RoleModelData)));
206 }
207
208- chosenElements = items;
209- mainPageStack.push(addtoPlaylist)
210+ var comp = Qt.createComponent("MusicaddtoPlaylist.qml")
211+ var addToPlaylist = comp.createObject(mainPageStack, {"chosenElements": items});
212+
213+ if (addToPlaylist === null) { // Error Handling
214+ console.log("Error creating object");
215+ }
216+
217+ mainPageStack.push(addToPlaylist)
218
219 tracklist.closeSelection()
220 }
221
222=== modified file 'MusicaddtoPlaylist.qml'
223--- MusicaddtoPlaylist.qml 2014-10-22 16:32:45 +0000
224+++ MusicaddtoPlaylist.qml 2014-10-23 22:16:21 +0000
225@@ -41,6 +41,8 @@
226 title: i18n.tr("Select playlist")
227 visible: false
228
229+ property var chosenElements: []
230+
231 head {
232 actions: [
233 Action {
234
235=== modified file 'Player.qml'
236--- Player.qml 2014-10-22 16:03:45 +0000
237+++ Player.qml 2014-10-23 22:16:21 +0000
238@@ -38,14 +38,14 @@
239 property string currentMetaFile: ""
240 property string currentMetaTitle: ""
241 property int currentIndex: -1
242- property alias duration: mediaPlayer.duration
243- property bool isPlaying: player.playbackState === MediaPlayer.PlayingState
244- property alias playbackState: mediaPlayer.playbackState
245- property alias position: mediaPlayer.position
246+ property int duration: 1
247+ readonly property bool isPlaying: player.playbackState === MediaPlayer.PlayingState
248+ readonly property var playbackState: mediaPlayerLoader.status == Loader.Ready ? mediaPlayerLoader.item.playbackState : MediaPlayer.StoppedState
249+ property int position: 0
250 property alias repeat: settings.repeat
251 property alias shuffle: settings.shuffle
252- property alias source: mediaPlayer.source
253- property alias volume: mediaPlayer.volume
254+ readonly property string source: mediaPlayerLoader.status == Loader.Ready ? mediaPlayerLoader.item.source : ""
255+ readonly property double volume: mediaPlayerLoader.status == Loader.Ready ? mediaPlayerLoader.item.volume : 1.0
256
257 signal stopped()
258
259@@ -62,10 +62,10 @@
260 onCountChanged: {
261 if (trackQueue.model.count === 1) {
262 player.currentIndex = 0;
263- player.source = Qt.resolvedUrl(trackQueue.model.get(0).filename)
264+ mediaPlayerLoader.item.source = Qt.resolvedUrl(trackQueue.model.get(0).filename)
265 } else if (trackQueue.model.count === 0) {
266 player.currentMetaFile = ""
267- player.source = ""
268+ mediaPlayerLoader.item.source = ""
269 }
270 }
271 }
272@@ -132,18 +132,18 @@
273 }
274
275 function pause() {
276- mediaPlayer.pause();
277+ mediaPlayerLoader.item.pause();
278 }
279
280 function play() {
281- mediaPlayer.play();
282+ mediaPlayerLoader.item.play();
283 }
284
285 function playSong(filepath, index) {
286- player.stop();
287+ stop();
288 currentIndex = index;
289- player.source = Qt.resolvedUrl(filepath);
290- player.play();
291+ setSource(filepath);
292+ play();
293 }
294
295 function previousSong(startPlaying) {
296@@ -151,61 +151,77 @@
297 }
298
299 function seek(position) {
300- mediaPlayer.seek(position);
301+ mediaPlayerLoader.item.seek(position);
302+ }
303+
304+ function setSource(filepath) {
305+ mediaPlayerLoader.item.source = Qt.resolvedUrl(filepath);
306+ }
307+
308+ function setVolume(volume) {
309+ mediaPlayerLoader.item.volume = volume
310 }
311
312 function stop() {
313- mediaPlayer.stop();
314+ mediaPlayerLoader.item.stop();
315 }
316
317 function toggle() {
318 if (player.playbackState == MediaPlayer.PlayingState) {
319- player.pause()
320+ pause()
321 }
322 else {
323- player.play()
324+ play()
325 }
326 }
327
328- MediaPlayer {
329- id: mediaPlayer
330- muted: false
331-
332- onSourceChanged: {
333- // Force invalid source to ""
334- if (source === undefined || source === false) {
335- source = ""
336- return
337- }
338-
339- if (source === "") {
340- currentIndex = -1
341- player.stop()
342- }
343- else {
344- var obj = trackQueue.model.get(player.currentIndex);
345- currentMetaAlbum = obj.album;
346-
347- if (obj.art !== undefined) { // FIXME: protect against not art property in playlists
348- currentMetaArt = obj.art;
349- }
350-
351- currentMetaArtist = obj.author;
352- currentMetaFile = obj.filename;
353- currentMetaTitle = obj.title;
354- }
355-
356- console.log("Source: " + source.toString())
357- console.log("Index: " + currentIndex)
358- }
359-
360- onStatusChanged: {
361- if (status == MediaPlayer.EndOfMedia) {
362- nextSong(true, false) // next track
363- }
364- }
365-
366- onStopped: player.stopped()
367+ Loader {
368+ id: mediaPlayerLoader
369+ asynchronous: true
370+ sourceComponent: Component {
371+ MediaPlayer {
372+ muted: false
373+
374+ onDurationChanged: player.duration = duration
375+ onPositionChanged: player.position = position
376+
377+ onSourceChanged: {
378+ // Force invalid source to ""
379+ if (source === undefined || source === false) {
380+ source = ""
381+ return
382+ }
383+
384+ if (source === "") {
385+ player.currentIndex = -1
386+ player.stop()
387+ }
388+ else {
389+ var obj = trackQueue.model.get(player.currentIndex);
390+ player.currentMetaAlbum = obj.album;
391+
392+ if (obj.art !== undefined) { // FIXME: protect against not art property in playlists
393+ player.currentMetaArt = obj.art;
394+ }
395+
396+ player.currentMetaArtist = obj.author;
397+ player.currentMetaFile = obj.filename;
398+ player.currentMetaTitle = obj.title;
399+ }
400+
401+ console.log("Source: " + source.toString())
402+ console.log("Index: " + player.currentIndex)
403+ }
404+
405+ onStatusChanged: {
406+ if (status == MediaPlayer.EndOfMedia) {
407+ nextSong(true, false) // next track
408+ }
409+ }
410+
411+ onStopped: player.stopped()
412+ }
413+ }
414 }
415 }
416
417
418=== modified file 'common/AlbumsPage.qml'
419--- common/AlbumsPage.qml 2014-10-23 12:58:25 +0000
420+++ common/AlbumsPage.qml 2014-10-23 22:16:21 +0000
421@@ -136,14 +136,21 @@
422 secondaryTextVisible: false
423
424 onClicked: {
425- songsPage.album = model.title;
426+ var comp = Qt.createComponent("SongsPage.qml")
427+ var songsPage = comp.createObject(mainPageStack,
428+ {
429+ "album": model.title,
430+ "covers": [{art: model.art}],
431+ "isAlbum": true,
432+ "genre": undefined,
433+ "title": i18n.tr("Album"),
434+ "line1": model.artist,
435+ "line2": model.title,
436+ });
437
438- songsPage.line1 = model.artist
439- songsPage.line2 = model.title
440- songsPage.isAlbum = true
441- songsPage.covers = [{art: model.art}]
442- songsPage.genre = undefined
443- songsPage.title = i18n.tr("Album")
444+ if (songsPage === null) { // Error Handling
445+ console.log("Error creating object");
446+ }
447
448 mainPageStack.push(songsPage)
449 }
450
451=== modified file 'common/ListItemActions/AddToPlaylist.qml'
452--- common/ListItemActions/AddToPlaylist.qml 2014-10-21 16:03:44 +0000
453+++ common/ListItemActions/AddToPlaylist.qml 2014-10-23 22:16:21 +0000
454@@ -27,8 +27,15 @@
455 property bool primed: false
456
457 onTriggered: {
458- chosenElements = [makeDict(model)];
459 console.debug("Debug: Add track to playlist");
460- mainPageStack.push(addtoPlaylist)
461+
462+ var comp = Qt.createComponent("../../MusicaddtoPlaylist.qml")
463+ var addToPlaylist = comp.createObject(mainPageStack, {"chosenElements": [makeDict(model)]});
464+
465+ if (addToPlaylist === null) { // Error Handling
466+ console.log("Error creating object");
467+ }
468+
469+ mainPageStack.push(addToPlaylist)
470 }
471 }
472
473=== modified file 'common/SongsPage.qml'
474--- common/SongsPage.qml 2014-10-23 11:43:10 +0000
475+++ common/SongsPage.qml 2014-10-23 22:16:21 +0000
476@@ -113,8 +113,14 @@
477 items.push(makeDict(albumtrackslist.model.get(albumtrackslist.selectedItems[i], albumtrackslist.model.RoleModelData)));
478 }
479
480- chosenElements = items;
481- mainPageStack.push(addtoPlaylist)
482+ var comp = Qt.createComponent("../MusicaddtoPlaylist.qml")
483+ var addToPlaylist = comp.createObject(mainPageStack, {"chosenElements": items});
484+
485+ if (addToPlaylist === null) { // Error Handling
486+ console.log("Error creating object");
487+ }
488+
489+ mainPageStack.push(addToPlaylist)
490
491 albumtrackslist.closeSelection()
492 }
493
494=== modified file 'music-app.qml'
495--- music-app.qml 2014-10-22 17:46:50 +0000
496+++ music-app.qml 2014-10-23 22:16:21 +0000
497@@ -562,7 +562,6 @@
498 // VARIABLES
499 property string musicName: i18n.tr("Music")
500 property string appVersion: '1.2'
501- property var chosenElements: []
502 property bool toolbarShown: musicToolbar.visible
503 property bool selectedAlbum: false
504
505@@ -649,7 +648,7 @@
506 tabs.pushNowPlaying();
507 }
508 else {
509- player.source = file;
510+ player.setSource(file);
511 }
512 }
513
514@@ -1016,21 +1015,9 @@
515 }
516 } // end of tabs
517
518- SongsPage {
519- id: songsPage
520- }
521-
522- AlbumsPage {
523- id: albumsPage
524- }
525-
526 MusicNowPlaying {
527 id: nowPlaying
528 }
529-
530- MusicaddtoPlaylist {
531- id: addtoPlaylist
532- }
533 }
534
535 Page {

Subscribers

People subscribed via source and target branches