[Android] Thread the subtitles loading
Geoffrey Métais
git at videolan.org
Tue May 24 15:40:11 CEST 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue May 24 15:25:52 2016 +0200| [670ea1010d4a425f86107fe91c1d5be2bd165c4a] | committer: Geoffrey Métais
Thread the subtitles loading
> https://code.videolan.org/videolan/vlc-android/commit/670ea1010d4a425f86107fe91c1d5be2bd165c4a
---
.../vlc/gui/video/VideoPlayerActivity.java | 59 ++++++++++++----------
1 file changed, 32 insertions(+), 27 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 38ab29c..7d944f6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -2947,35 +2947,40 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
}
private void getSubtitles() {
- String subtitleList_serialized = mSettings.getString(PreferencesActivity.VIDEO_SUBTITLE_FILES, null);
- ArrayList<String> prefsList = new ArrayList<>();
- 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) {}
- }
- prefsList.addAll(MediaDatabase.getInstance().getSubtitles(mUri.getPath()));
- for(String x : prefsList){
- if(!mSubtitleSelectedFiles.contains(x))
- mSubtitleSelectedFiles.add(x);
- }
+ final String subtitleList_serialized = mSettings.getString(PreferencesActivity.VIDEO_SUBTITLE_FILES, null);
+ VLCApplication.runBackground(new Runnable() {
+ @Override
+ public void run() {
+ ArrayList<String> prefsList = new ArrayList<>();
+ 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) {}
+ }
+ prefsList.addAll(MediaDatabase.getInstance().getSubtitles(mUri.getPath()));
+ for(String x : prefsList){
+ if(!mSubtitleSelectedFiles.contains(x))
+ mSubtitleSelectedFiles.add(x);
+ }
- // Add any selected subtitle file from the file picker
- if(mSubtitleSelectedFiles.size() > 0) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- for(String file : mSubtitleSelectedFiles) {
- Log.i(TAG, "Adding user-selected subtitle " + file);
- mService.addSubtitleTrack(file);
- }
+ // Add any selected subtitle file from the file picker
+ if(mSubtitleSelectedFiles.size() > 0) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ for(String file : mSubtitleSelectedFiles) {
+ Log.i(TAG, "Adding user-selected subtitle " + file);
+ mService.addSubtitleTrack(file);
+ }
+ }
+ });
}
- });
- }
+ }
+ });
}
@SuppressWarnings("deprecation")
More information about the Android
mailing list