[Android] Always check for subtitles

Geoffrey Métais git at videolan.org
Fri Jul 20 11:36:42 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Jul 20 11:18:42 2018 +0200| [179b4b08d14f338fb033bdb817a15a8404dfe77e] | committer: Geoffrey Métais

Always check for subtitles

Fixes #615

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

 .../org/videolan/vlc/gui/video/VideoPlayerActivity.java | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 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 54c87c01d..b01829b2f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1640,6 +1640,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         setESTracks();
         if (mTitle != null && mTitle.length() == 0)
             mTitle.setText(mw.getTitle());
+        // Get possible subtitles
+        getSubtitles();
     }
 
     private void encounteredError() {
@@ -2849,9 +2851,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             else
                 mService.loadUri(mUri);
 
-            // Get possible subtitles
-            getSubtitles();
-
             // Get the title
             if (itemTitle == null && !TextUtils.equals(mUri.getScheme(), "content"))
                 title = mUri.getLastPathSegment();
@@ -2860,8 +2859,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         } else {
             mService.loadLastPlaylist(Constants.PLAYLIST_TYPE_VIDEO);
         }
-        if (itemTitle != null)
-            title = itemTitle;
+        if (itemTitle != null) title = itemTitle;
         mTitle.setText(title);
 
         if (mWasPaused) {
@@ -2903,8 +2901,13 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                 }
             }
 
-            if (!TextUtils.equals(mUri.getScheme(), "content"))
-                prefsList.addAll(MediaDatabase.getInstance().getSubtitles(mUri.getLastPathSegment()));
+            String mediaTitle = null;
+            if (mUri != null && !TextUtils.equals(mUri.getScheme(), "content")) mediaTitle = mUri.getLastPathSegment();
+            else if (mService != null) {
+                final MediaWrapper mw = mService.getCurrentMediaWrapper();
+                if (mw != null) mediaTitle = FileUtils.getFileNameFromPath(mService.getCurrentMediaWrapper().getLocation());
+            }
+            if (mediaTitle != null) prefsList.addAll(MediaDatabase.getInstance().getSubtitles(mediaTitle));
 
             return prefsList;
         }



More information about the Android mailing list