[Android] Save video pause status with a flag

Edward Wang git at videolan.org
Mon Jan 5 22:15:43 CET 2015


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Mon Jan  5 15:34:52 2015 -0500| [6f2f94919e2503c17612f1763f42647111a5c29f] | committer: Edward Wang

Save video pause status with a flag

Close #10015

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=6f2f94919e2503c17612f1763f42647111a5c29f
---

 .../org/videolan/vlc/gui/PreferencesActivity.java   |    1 +
 .../videolan/vlc/gui/video/VideoPlayerActivity.java |   19 +++++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
index fc7d695..c22bded 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
@@ -63,6 +63,7 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP
 
     public final static String NAME = "VlcSharedPreferences";
     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 int RESULT_RESCAN = RESULT_FIRST_USER + 1;
     public final static int RESULT_RESTART = RESULT_FIRST_USER + 2;
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 589587b..b36adfd 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -412,6 +412,8 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
         // only (like desktop VLC). We don't want the custom subtitle files
         // to persist forever with this video.
         editor.putString(PreferencesActivity.VIDEO_SUBTITLE_FILES, null);
+        // Paused flag - per session too, like the subs list.
+        editor.remove(PreferencesActivity.VIDEO_PAUSED);
         editor.commit();
 
         IntentFilter filter = new IntentFilter();
@@ -495,6 +497,8 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
             return;
         }
 
+        Boolean isPaused = !mLibVLC.isPlaying();
+
         long time = mLibVLC.getTime();
         long length = mLibVLC.getLength();
         //remove saved position if in the last 5 seconds
@@ -527,6 +531,10 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
                 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
         String subtitleList_serialized = null;
         if(mSubtitleSelectedFiles.size() > 0) {
@@ -2391,6 +2399,17 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
                     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
             String subtitleList_serialized = mSettings.getString(PreferencesActivity.VIDEO_SUBTITLE_FILES, null);
             ArrayList<String> prefsList = new ArrayList<String>();



More information about the Android mailing list