[Android] fix local path to uri helper

Thomas Guillem git at videolan.org
Thu May 28 16:37:42 CEST 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu May 28 16:37:21 2015 +0200| [c095d88214c004874b825e0b8d5e92bebee387b0] | committer: Thomas Guillem

fix local path to uri helper

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=c095d88214c004874b825e0b8d5e92bebee387b0
---

 libvlc/src/org/videolan/libvlc/util/AndroidUtil.java |    6 +-----
 vlc-android/src/org/videolan/vlc/MediaWrapper.java   |    8 +++++---
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/libvlc/src/org/videolan/libvlc/util/AndroidUtil.java b/libvlc/src/org/videolan/libvlc/util/AndroidUtil.java
index c7a7dd3..243abb9 100644
--- a/libvlc/src/org/videolan/libvlc/util/AndroidUtil.java
+++ b/libvlc/src/org/videolan/libvlc/util/AndroidUtil.java
@@ -85,10 +85,6 @@ public class AndroidUtil {
         if (path == null) {
             throw new NullPointerException("Cannot convert null path!");
         }
-        Uri uri = Uri.parse(path);
-        if (uri.getScheme() == null)
-            return Uri.parse("file://" + path).toString();
-        else
-            return uri.toString();
+        return Uri.fromFile(new File(path)).toString();
     }
 }
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/MediaWrapper.java b/vlc-android/src/org/videolan/vlc/MediaWrapper.java
index 0a3e2f0..dbe300a 100644
--- a/vlc-android/src/org/videolan/vlc/MediaWrapper.java
+++ b/vlc-android/src/org/videolan/vlc/MediaWrapper.java
@@ -20,6 +20,7 @@
 
 package org.videolan.vlc;
 
+import java.io.File;
 import java.util.Locale;
 
 import org.videolan.libvlc.MediaPlayer;
@@ -80,9 +81,10 @@ public class MediaWrapper implements Parcelable {
 
     private static Uri getUri(String mrl) {
         Uri uri = Uri.parse(mrl);
-        if (uri.getScheme() == null)
-            return Uri.parse("file://" + mrl);
-        else
+        if (uri.getScheme() == null) {
+            Log.w(TAG, "invalid mrl: " + mrl);
+            return Uri.fromFile(new File(mrl));
+        } else
             return uri;
     }
 



More information about the Android mailing list