[Android] Get artist songs sorted by albums

Geoffrey Métais git at videolan.org
Tue Jan 3 10:57:40 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jan  2 19:17:33 2017 +0100| [c9ec2ddbfda7ef075a2e11cff0e531944e9ab480] | committer: Geoffrey Métais

Get artist songs sorted by albums

> https://code.videolan.org/videolan/vlc-android/commit/c9ec2ddbfda7ef075a2e11cff0e531944e9ab480
---

 medialibrary/jni/medialibrary.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/medialibrary/jni/medialibrary.cpp b/medialibrary/jni/medialibrary.cpp
index 1d61d30..ea9b097 100644
--- a/medialibrary/jni/medialibrary.cpp
+++ b/medialibrary/jni/medialibrary.cpp
@@ -437,7 +437,12 @@ jobjectArray
 getMediaFromArtist(JNIEnv* env, jobject thiz, jobject medialibrary, jlong id)
 {
     AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, medialibrary);
-    std::vector<medialibrary::MediaPtr> mediaList = aml->mediaFromArtist(id);
+    std::vector<medialibrary::AlbumPtr> albumList = aml->albumsFromArtist(id);
+    std::vector<medialibrary::MediaPtr> mediaList;
+    for (medialibrary::AlbumPtr album : albumList) {
+        std::vector<medialibrary::MediaPtr> tracks = album->tracks();
+        mediaList.insert(std::end(mediaList), std::begin(tracks), std::end(tracks));
+    }
     jobjectArray mediaRefs = (jobjectArray) env->NewObjectArray(mediaList.size(), ml_fields.MediaWrapper.clazz, NULL);
     int index = -1;
     for(medialibrary::MediaPtr const& media : mediaList) {



More information about the Android mailing list