[Android] Send encoded mrl to medialibrary

Geoffrey Métais git at videolan.org
Wed Jan 11 14:21:13 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jan 11 11:47:34 2017 +0100| [a84a7d0dd4da327c9888b97e29b7884a1a7c298a] | committer: Geoffrey Métais

Send encoded mrl to medialibrary

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

 medialibrary/src/org/videolan/medialibrary/Medialibrary.java | 12 ++++++------
 medialibrary/src/org/videolan/medialibrary/Tools.java        | 10 ++++++++++
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index 67f674a..dc3140d 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -70,7 +70,7 @@ public class Medialibrary {
 
     public void banFolder(String path) {
         if (mIsInitiated && new File(path).exists())
-            nativeBanFolder(path);
+            nativeBanFolder(Tools.encodeMrl(path));
     }
 
     public String[] getDevices() {
@@ -78,15 +78,15 @@ public class Medialibrary {
     }
 
     public void addDevice(String uuid, String path, boolean removable) {
-        nativeAddDevice(uuid, path, removable);
+        nativeAddDevice(uuid, Tools.encodeMrl(path), removable);
     }
 
     public void discover(String path) {
-        nativeDiscover(path);
+        nativeDiscover(Tools.encodeMrl(path));
     }
 
     public void removeFolder(String path) {
-        nativeRemoveEntryPoint(path);
+        nativeRemoveEntryPoint(Tools.encodeMrl(path));
     }
 
     public String[] getFoldersList() {
@@ -202,11 +202,11 @@ public class Medialibrary {
         return mIsInitiated ? nativeGetMedia(id) : null;
     }
     public MediaWrapper getMedia(String mrl) {
-        return mIsInitiated ? nativeGetMediaFromMrl(mrl) : null;
+        return mIsInitiated ? nativeGetMediaFromMrl(Tools.encodeMrl(mrl)) : null;
     }
 
     public MediaWrapper addMedia(String mrl) {
-        return mIsInitiated ? nativeAddMedia(mrl) : null;
+        return mIsInitiated ? nativeAddMedia(Tools.encodeMrl(mrl)) : null;
     }
 
     public long getId() {
diff --git a/medialibrary/src/org/videolan/medialibrary/Tools.java b/medialibrary/src/org/videolan/medialibrary/Tools.java
index 74216c1..21feb7a 100644
--- a/medialibrary/src/org/videolan/medialibrary/Tools.java
+++ b/medialibrary/src/org/videolan/medialibrary/Tools.java
@@ -6,6 +6,7 @@ import android.os.Environment;
 import android.support.annotation.Nullable;
 import android.text.TextUtils;
 
+import org.videolan.libvlc.util.VLCUtil;
 import org.videolan.medialibrary.media.MediaLibraryItem;
 import org.videolan.medialibrary.media.MediaWrapper;
 
@@ -15,6 +16,7 @@ import java.util.Locale;
 
 public class Tools {
 
+    private static StringBuilder sb = new StringBuilder();
 
     /*
      * Convert file:// uri from real path to emulated FS path.
@@ -100,4 +102,12 @@ public class Tools {
         }
         return time;
     }
+
+    public static String encodeMrl(String mrl) {
+        sb.setLength(0);
+        if (mrl.startsWith("/"))
+            sb.append("file://");
+        sb.append(VLCUtil.UriFromMrl(mrl).toString());
+        return sb.toString();
+    }
 }



More information about the Android mailing list