[Android] Medialibrary: rename media call

Geoffrey Métais git at videolan.org
Tue Sep 11 15:51:33 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Sep 11 15:46:01 2018 +0200| [0fdd941cc34892e76527c799b5a8860f269ddc14] | committer: Geoffrey Métais

Medialibrary: rename media call

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

 medialibrary/jni/medialibrary.cpp                            | 12 ++++++++++++
 .../src/org/videolan/medialibrary/media/MediaWrapper.java    |  6 ++++++
 2 files changed, 18 insertions(+)

diff --git a/medialibrary/jni/medialibrary.cpp b/medialibrary/jni/medialibrary.cpp
index 5c30e2eac..9e483a48b 100644
--- a/medialibrary/jni/medialibrary.cpp
+++ b/medialibrary/jni/medialibrary.cpp
@@ -1417,6 +1417,17 @@ setMediaThumbnail(JNIEnv* env, jobject thiz, jobject medialibrary, jlong id, jst
     env->ReleaseStringUTFChars(mrl, char_mrl);
 }
 
+void
+setMediaTitle(JNIEnv* env, jobject thiz, jobject medialibrary, jlong id, jstring title)
+{
+    AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, medialibrary);
+    medialibrary::MediaPtr media = aml->media(id);
+    if (media == nullptr) return;
+    const char *char_name = env->GetStringUTFChars(title, JNI_FALSE);
+    media->setTitle(char_name);
+    env->ReleaseStringUTFChars(title, char_name);
+}
+
 /*
  * Playlist methods
  */
@@ -1628,6 +1639,7 @@ static JNINativeMethod media_methods[] = {
     {"nativeSetMediaStringMetadata", "(Lorg/videolan/medialibrary/Medialibrary;JILjava/lang/String;)V", (void*)setMediaStringMetadata },
     {"nativeSetMediaLongMetadata", "(Lorg/videolan/medialibrary/Medialibrary;JIJ)V", (void*)setMediaLongMetadata },
     {"nativeSetMediaThumbnail", "(Lorg/videolan/medialibrary/Medialibrary;JLjava/lang/String;)V", (void*)setMediaThumbnail },
+    {"nativeSetMediaTitle", "(Lorg/videolan/medialibrary/Medialibrary;JLjava/lang/String;)V", (void*)setMediaTitle },
 };
 
 static JNINativeMethod album_methods[] = {
diff --git a/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java b/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java
index cf1908fb7..3e1751bb4 100644
--- a/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java
+++ b/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java
@@ -466,6 +466,11 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
         mTitle = title;
     }
 
+    public void rename(String name) {
+        final Medialibrary ml = Medialibrary.getInstance();
+        if (mId != 0 && ml.isInitiated()) nativeSetMediaTitle(ml, mId, name);
+    }
+
     public void setArtist(String artist){
         mArtist = artist;
     }
@@ -639,6 +644,7 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
     private native void nativeSetMediaStringMetadata(Medialibrary ml, long id, int metaDataType, String metadataValue);
     private native void nativeSetMediaLongMetadata(Medialibrary ml, long id, int metaDataType, long metadataValue);
     private native void nativeSetMediaThumbnail(Medialibrary ml, long id, String mrl);
+    private native void nativeSetMediaTitle(Medialibrary ml, long id, String name);
 
     @Nullable
     public Media.Slave[] getSlaves() {



More information about the Android mailing list