[Android] Save picked subtitle as a slave for current media

Geoffrey Métais git at videolan.org
Tue May 31 18:27:06 CEST 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue May 31 18:14:02 2016 +0200| [ad1384befe7b596fe0aec3f3efcf69f604e57db5] | committer: Geoffrey Métais

Save picked subtitle as a slave for current media

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

 .../org/videolan/vlc/gui/video/VideoPlayerActivity.java   | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 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 ae75223..b346449 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -933,15 +933,20 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     }
 
     @Override
-    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+    protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
         if(data == null) return;
 
         if(data.getData() == null)
             Log.d(TAG, "Subtitle selection dialog was cancelled");
-
-        String subtitlesPath = data.getData().getPath();
-        mSubtitleSelectedFiles.add(subtitlesPath);
-        mService.addSubtitleTrack(subtitlesPath);
+        else {
+            mService.addSubtitleTrack(data.getData());
+            VLCApplication.runBackground(new Runnable() {
+                @Override
+                public void run() {
+                    MediaDatabase.getInstance().saveSlave(mService.getCurrentMediaLocation(), Media.Slave.Type.Subtitle, 2, data.getDataString());
+                }
+            });
+        }
     }
 
     public static void start(Context context, Uri uri) {



More information about the Android mailing list