[Android] Properly restore position in video on load

Geoffrey Métais git at videolan.org
Sun Jun 5 11:54:54 CEST 2016


vlc-android | branch: 2.0.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Sat Jun  4 15:17:40 2016 +0200| [bd46377664f653979fc3ec5058a90820fe5d163e] | committer: Geoffrey Métais

Properly restore position in video on load

(cherry picked from commit fb435f60dec511919da453fe6293350692b2ce40)

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

 .../org/videolan/vlc/gui/video/VideoPlayerActivity.java | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 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 699dc1e..f01aa67 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -2868,7 +2868,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         boolean fromStart = false;
         String itemTitle = null;
         int positionInPlaylist = -1;
-        long intentPosition = -1; // position passed in by intent (ms)
+        long savedTime = -1; // position passed in by intent (ms)
         Intent intent = getIntent();
         String action = intent.getAction();
         Bundle extras = getIntent().getExtras();
@@ -2937,13 +2937,15 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                 intent.putExtra(PLAY_EXTRA_FROM_START, false);
                 if (fromStart || mService.isPlaying())
                     media.setTime(0l);
+                else
+                    savedTime = media.getTime();
 
                 mLastAudioTrack = media.getAudioTrack();
                 mLastSpuTrack = media.getSpuTrack();
             } else {
                 // not in media library
 
-                if (intentPosition > 0 && mAskResume) {
+                if (savedTime > 0 && mAskResume) {
                     showConfirmResumeDialog();
                     return;
                 } else {
@@ -2956,7 +2958,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                             Editor editor = mSettings.edit();
                             editor.putLong(PreferencesActivity.VIDEO_RESUME_TIME, -1);
                             Util.commitPreferences(editor);
-                            intentPosition = rTime;
+                            savedTime = rTime;
                         }
                     }
                 }
@@ -2990,11 +2992,10 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
 
             if (seek) {
                 // Set time
-                long resumeTime = intentPosition;
-                if (intentPosition <= 0 && media != null && media.getTime() > 0l)
-                    resumeTime = media.getTime();
-                if (resumeTime > 0)
-                    seek(resumeTime);
+                if (savedTime <= 0 && media != null && media.getTime() > 0l)
+                    savedTime = media.getTime();
+                if (savedTime > 0)
+                    seek(savedTime);
             }
 
             // Get possible subtitles



More information about the Android mailing list