<div dir="ltr">Slight modification in  } catch (Exception e) { block, to ensure dumb Uri starting with content:/ and containing a file path are handled.<div>Because getContentResolver().query(..) throws an exception in this case.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 7, 2014 at 10:56 AM, Geoffrey Métais <span dir="ltr"><<a href="mailto:geoffrey.metais@gmail.com" target="_blank">geoffrey.metais@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Allows to read files given through third-party app content provider,<br>
like Archos Media Player, and try the data.getPath() if no content is found..<br>
---<br>
 .../vlc/gui/video/VideoPlayerActivity.java         | 57 ++++++++++++----------<br>
 1 file changed, 30 insertions(+), 27 deletions(-)<br>
<br>
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java<br>
index 4b41784..0d30978 100644<br>
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java<br>
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java<br>
@@ -79,6 +79,7 @@ import android.graphics.PixelFormat;<br>
 import android.media.AudioManager;<br>
 import android.media.AudioManager.OnAudioFocusChangeListener;<br>
 import android.media.MediaRouter;<br>
+import android.net.Uri;<br>
 import android.os.Build;<br>
 import android.os.Bundle;<br>
 import android.os.Environment;<br>
@@ -2101,6 +2102,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {<br>
         String title = getResources().getString(R.string.title);<br>
         boolean dontParse = false;<br>
         boolean fromStart = false;<br>
+        Uri data;<br>
         String itemTitle = null;<br>
         int itemPosition = -1; // Index in the media list as passed by AudioServer (used only for vout transition internally)<br>
         long intentPosition = -1; // position passed in by intent (ms)<br>
@@ -2108,33 +2110,17 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {<br>
         if (getIntent().getAction() != null<br>
                 && getIntent().getAction().equals(Intent.ACTION_VIEW)) {<br>
             /* Started from external application 'content' */<br>
-            if (getIntent().getData() != null<br>
-                    && getIntent().getData().getScheme() != null<br>
-                    && getIntent().getData().getScheme().equals("content")) {<br>
+            data = getIntent().getData();<br>
+            if (data != null<br>
+                    && data.getScheme() != null<br>
+                    && data.getScheme().equals("content")) {<br>
<br>
-                // Media or MMS URI<br>
-                if(getIntent().getData().getHost().equals("media")<br>
-                        || getIntent().getData().getHost().equals("mms")) {<br>
-                    try {<br>
-                        Cursor cursor = getContentResolver().query(getIntent().getData(),<br>
-                                new String[]{ MediaStore.Video.Media.DATA }, null, null, null);<br>
-                        if (cursor != null) {<br>
-                            int column_index = cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);<br>
-                            if (cursor.moveToFirst())<br>
-                                mLocation = LibVLC.PathToURI(cursor.getString(column_index));<br>
-                            cursor.close();<br>
-                        }<br>
-                    } catch (Exception e) {<br>
-                        Log.e(TAG, "Couldn't read the file from media or MMS");<br>
-                        encounteredError();<br>
-                    }<br>
-                }<br>
<br>
                 // Mail-based apps - download the stream to a temporary file and play it<br>
-                else if(getIntent().getData().getHost().equals("com.fsck.k9.attachmentprovider")<br>
-                       || getIntent().getData().getHost().equals("gmail-ls")) {<br>
+                if(data.getHost().equals("com.fsck.k9.attachmentprovider")<br>
+                       || data.getHost().equals("gmail-ls")) {<br>
                     try {<br>
-                        Cursor cursor = getContentResolver().query(getIntent().getData(),<br>
+                        Cursor cursor = getContentResolver().query(data,<br>
                                 new String[]{MediaStore.MediaColumns.DISPLAY_NAME}, null, null, null);<br>
                         if (cursor != null) {<br>
                             cursor.moveToFirst();<br>
@@ -2142,7 +2128,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {<br>
                             cursor.close();<br>
                             Log.i(TAG, "Getting file " + filename + " from content:// URI");<br>
<br>
-                            InputStream is = getContentResolver().openInputStream(getIntent().getData());<br>
+                            InputStream is = getContentResolver().openInputStream(data);<br>
                             OutputStream os = new FileOutputStream(Environment.getExternalStorageDirectory().getPath() + "/Download/" + filename);<br>
                             byte[] buffer = new byte[1024];<br>
                             int bytesRead = 0;<br>
@@ -2158,10 +2144,27 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {<br>
                         encounteredError();<br>
                     }<br>
                 }<br>
-<br>
-                // other content-based URI (probably file pickers)<br>
+                // Media or MMS URI<br>
                 else {<br>
-                    mLocation = getIntent().getData().getPath();<br>
+                    try {<br>
+                        Cursor cursor = getContentResolver().query(data,<br>
+                                new String[]{ MediaStore.Video.Media.DATA }, null, null, null);<br>
+                        if (cursor != null) {<br>
+                            int column_index = cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);<br>
+                            if (cursor.moveToFirst())<br>
+                                mLocation = LibVLC.PathToURI(cursor.getString(column_index));<br>
+                            cursor.close();<br>
+                        }<br>
+                        // other content-based URI (probably file pickers)<br>
+                        else {<br>
+                            mLocation = data.getPath();<br>
+                        }<br>
+                    } catch (Exception e) {<br>
+                        mLocation = data.getPath();<br>
+                        if (!mLocation.startsWith("file://"))<br>
+                            mLocation = "file://"+mLocation;<br>
+                        Log.e(TAG, "Couldn't read the file from media or MMS");<br>
+                    }<br>
                 }<br>
             } /* External application */<br>
             else if (getIntent().getDataString() != null) {<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.1<br>
<br>
</font></span></blockquote></div><br></div>