Commit 6f2f9491 authored by Edward Wang's avatar Edward Wang
Browse files

Save video pause status with a flag

Close #10015
parent 3d17a284
...@@ -63,6 +63,7 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP ...@@ -63,6 +63,7 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP
public final static String NAME = "VlcSharedPreferences"; public final static String NAME = "VlcSharedPreferences";
public final static String VIDEO_RESUME_TIME = "VideoResumeTime"; public final static String VIDEO_RESUME_TIME = "VideoResumeTime";
public final static String VIDEO_PAUSED = "VideoPaused";
public final static String VIDEO_SUBTITLE_FILES = "VideoSubtitleFiles"; public final static String VIDEO_SUBTITLE_FILES = "VideoSubtitleFiles";
public final static int RESULT_RESCAN = RESULT_FIRST_USER + 1; public final static int RESULT_RESCAN = RESULT_FIRST_USER + 1;
public final static int RESULT_RESTART = RESULT_FIRST_USER + 2; public final static int RESULT_RESTART = RESULT_FIRST_USER + 2;
......
...@@ -412,6 +412,8 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay ...@@ -412,6 +412,8 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
// only (like desktop VLC). We don't want the custom subtitle files // only (like desktop VLC). We don't want the custom subtitle files
// to persist forever with this video. // to persist forever with this video.
editor.putString(PreferencesActivity.VIDEO_SUBTITLE_FILES, null); editor.putString(PreferencesActivity.VIDEO_SUBTITLE_FILES, null);
// Paused flag - per session too, like the subs list.
editor.remove(PreferencesActivity.VIDEO_PAUSED);
editor.commit(); editor.commit();
IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter();
...@@ -495,6 +497,8 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay ...@@ -495,6 +497,8 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
return; return;
} }
Boolean isPaused = !mLibVLC.isPlaying();
long time = mLibVLC.getTime(); long time = mLibVLC.getTime();
long length = mLibVLC.getLength(); long length = mLibVLC.getLength();
//remove saved position if in the last 5 seconds //remove saved position if in the last 5 seconds
...@@ -527,6 +531,10 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay ...@@ -527,6 +531,10 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
editor.putLong(PreferencesActivity.VIDEO_RESUME_TIME, time); editor.putLong(PreferencesActivity.VIDEO_RESUME_TIME, time);
} }
} }
if(isPaused)
Log.d(TAG, "Video paused - saving flag");
editor.putBoolean(PreferencesActivity.VIDEO_PAUSED, isPaused);
// Save selected subtitles // Save selected subtitles
String subtitleList_serialized = null; String subtitleList_serialized = null;
if(mSubtitleSelectedFiles.size() > 0) { if(mSubtitleSelectedFiles.size() > 0) {
...@@ -2391,6 +2399,17 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay ...@@ -2391,6 +2399,17 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
mLibVLC.setTime(intentPosition); mLibVLC.setTime(intentPosition);
} }
// Paused flag
boolean wasPaused = mSettings.getBoolean(PreferencesActivity.VIDEO_PAUSED, false);
if(wasPaused) {
Log.d(TAG, "Video was previously paused, resuming in paused mode");
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mLibVLC.pause();
}}, 500);
}
// Get possible subtitles // Get possible subtitles
String subtitleList_serialized = mSettings.getString(PreferencesActivity.VIDEO_SUBTITLE_FILES, null); String subtitleList_serialized = mSettings.getString(PreferencesActivity.VIDEO_SUBTITLE_FILES, null);
ArrayList<String> prefsList = new ArrayList<String>(); ArrayList<String> prefsList = new ArrayList<String>();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment