[Android] Thread subtitles retrieval
Geoffrey Métais
git at videolan.org
Fri Mar 18 15:07:30 CET 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Mar 18 15:04:20 2016 +0100| [3481501f10d76a49e4bfa832b3bb2df1153877d6] | committer: Geoffrey Métais
Thread subtitles retrieval
> https://code.videolan.org/videolan/vlc-android/commit/3481501f10d76a49e4bfa832b3bb2df1153877d6
---
.../vlc/gui/video/VideoPlayerActivity.java | 36 ++++++++++++----------
1 file changed, 20 insertions(+), 16 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 97cd2d2..87e719c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -293,7 +293,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
* It is possible to have multiple custom subs in one session
* (just like desktop VLC allows you as well.)
*/
- private final ArrayList<String> mSubtitleSelectedFiles = new ArrayList<String>();
+ private final volatile ArrayList<String> mSubtitleSelectedFiles = new ArrayList<>();
/**
* Flag to indicate whether the media should be paused once loaded
@@ -2813,21 +2813,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
seek(resumeTime);
// Get possible subtitles
- String subtitleList_serialized = mSettings.getString(PreferencesActivity.VIDEO_SUBTITLE_FILES, null);
- ArrayList<String> prefsList = new ArrayList<String>();
- if(subtitleList_serialized != null) {
- ByteArrayInputStream bis = new ByteArrayInputStream(subtitleList_serialized.getBytes());
- try {
- ObjectInputStream ois = new ObjectInputStream(bis);
- prefsList = (ArrayList<String>)ois.readObject();
- } catch(ClassNotFoundException e) {}
- catch (StreamCorruptedException e) {}
- catch (IOException e) {}
- }
- for(String x : prefsList){
- if(!mSubtitleSelectedFiles.contains(x))
- mSubtitleSelectedFiles.add(x);
- }
+ getSubtitles();
// Get the title
if (itemTitle == null)
@@ -2847,6 +2833,24 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mTitle.setText(title);
}
+ private void getSubtitles() {
+ String subtitleList_serialized = mSettings.getString(PreferencesActivity.VIDEO_SUBTITLE_FILES, null);
+ ArrayList<String> prefsList = new ArrayList<String>();
+ if(subtitleList_serialized != null) {
+ ByteArrayInputStream bis = new ByteArrayInputStream(subtitleList_serialized.getBytes());
+ try {
+ ObjectInputStream ois = new ObjectInputStream(bis);
+ prefsList = (ArrayList<String>)ois.readObject();
+ } catch(ClassNotFoundException e) {}
+ catch (StreamCorruptedException e) {}
+ catch (IOException e) {}
+ }
+ for(String x : prefsList){
+ if(!mSubtitleSelectedFiles.contains(x))
+ mSubtitleSelectedFiles.add(x);
+ }
+ }
+
@SuppressWarnings("deprecation")
private int getScreenRotation(){
WindowManager wm = (WindowManager) VLCApplication.getAppContext().getSystemService(Context.WINDOW_SERVICE);
More information about the Android
mailing list