[Android] Get subtitles from new subs picker

Geoffrey Métais git at videolan.org
Tue Jun 30 10:36:16 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jun 30 10:34:27 2015 +0200| [39d862b152247effb87b698a512aaeaf2094b212] | committer: Geoffrey Métais

Get subtitles from new subs picker

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

 .../videolan/vlc/gui/video/VideoPlayerActivity.java   |   17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 0a4df44..dcde299 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -807,18 +807,12 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         if(data == null) return;
 
-        if(data.getDataString() == null) {
+        if(data.getData() == null)
             Log.d(TAG, "Subtitle selection dialog was cancelled");
-        }
-        if(data.getData() == null) return;
 
-        String subtitlePath = data.getData().getPath();
-        if(requestCode == CommonDialogs.INTENT_SPECIFIC) {
-            Log.d(TAG, "Specific subtitle file: " + subtitlePath);
-        } else if(requestCode == CommonDialogs.INTENT_GENERIC) {
-            Log.d(TAG, "Generic subtitle file: " + subtitlePath);
-        }
-        mSubtitleSelectedFiles.add(subtitlePath);
+        String subtitlesPath = data.getData().getPath();
+        mSubtitleSelectedFiles.add(subtitlesPath);
+        MediaPlayer().addSubtitleTrack(subtitlesPath);
     }
 
     public static void start(Context context, Uri uri) {
@@ -2012,7 +2006,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                     return true;
                 } else if (item.getItemId() == R.id.video_menu_subtitles_picker) {
                     Intent filePickerIntent = new Intent(context, FilePickerActivity.class);
-                    filePickerIntent.setData(Uri.parse(Strings.getParent(MediaPlayer().getMedia().getUri().toString())));
+                    if (TextUtils.equals(MediaPlayer().getMedia().getUri().getScheme(), "file"))
+                        filePickerIntent.setData(Uri.parse(Strings.getParent(MediaPlayer().getMedia().getUri().toString())));
                     context.startActivityForResult(filePickerIntent, 0);
                     return true;
                 }



More information about the Android mailing list