[Android] Implement getSortedAudio call

Geoffrey Métais git at videolan.org
Wed Apr 4 18:35:00 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Mar  6 17:47:33 2018 +0100| [6111c98ed4840c042afa69538eacd9be9a4854d6] | committer: Geoffrey Métais

Implement getSortedAudio call

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

 medialibrary/jni/medialibrary.cpp                            | 7 +++++++
 medialibrary/src/org/videolan/medialibrary/Medialibrary.java | 6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/medialibrary/jni/medialibrary.cpp b/medialibrary/jni/medialibrary.cpp
index 95a618b8b..51374e198 100644
--- a/medialibrary/jni/medialibrary.cpp
+++ b/medialibrary/jni/medialibrary.cpp
@@ -317,6 +317,12 @@ getRecentAudio(JNIEnv* env, jobject thiz)
     return getInternalAudio(env, thiz, medialibrary::SortingCriteria::InsertionDate, true);
 }
 
+jobjectArray
+getSortedAudio(JNIEnv* env, jobject thiz, jint sortingCriteria, jboolean desc)
+{
+    return getInternalAudio(env, thiz, static_cast<medialibrary::SortingCriteria>(sortingCriteria), desc);
+}
+
 jobject
 search(JNIEnv* env, jobject thiz, jstring query)
 {
@@ -793,6 +799,7 @@ static JNINativeMethod methods[] = {
     {"nativeGetSortedVideos", "(IZ)[Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)getSortedVideos },
     {"nativeGetRecentVideos", "()[Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)getRecentVideos },
     {"nativeGetAudio", "()[Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)getAudio },
+    {"nativeGetSortedAudio", "(IZ)[Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)getSortedAudio },
     {"nativeGetRecentAudio", "()[Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)getRecentAudio },
     {"nativeSearch", "(Ljava/lang/String;)Lorg/videolan/medialibrary/media/SearchAggregate;", (void*)search},
     {"nativeSearchMedia", "(Ljava/lang/String;)Lorg/videolan/medialibrary/media/MediaSearchAggregate;", (void*)searchMedia},
diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index b3092f068..19bfab027 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -181,6 +181,11 @@ public class Medialibrary {
         return mIsInitiated ? nativeGetAudio() : new MediaWrapper[0];
     }
 
+    @WorkerThread
+    public MediaWrapper[] getAudio(int sort, boolean desc) {
+        return mIsInitiated ? nativeGetSortedAudio(sort, desc) : new MediaWrapper[0];
+    }
+
     @WorkerThread
     public MediaWrapper[] getRecentAudio() {
         return mIsInitiated ? nativeGetRecentAudio() : new MediaWrapper[0];
@@ -670,6 +675,7 @@ public class Medialibrary {
     private native MediaWrapper[] nativeGetSortedVideos(int sort, boolean desc);
     private native MediaWrapper[] nativeGetRecentVideos();
     private native MediaWrapper[] nativeGetAudio();
+    private native MediaWrapper[] nativeGetSortedAudio(int sort, boolean desc);
     private native MediaWrapper[] nativeGetRecentAudio();
     private native int nativeGetVideoCount();
     private native int nativeGetAudioCount();



More information about the Android mailing list