[Android] Restore 'position' intent extra for video

Geoffrey Métais git at videolan.org
Wed Jun 29 11:43:12 CEST 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jun 29 11:41:14 2016 +0200| [eaacc9ba853edb3bc80d91f2bedefbd20d0eac86] | committer: Geoffrey Métais

Restore 'position' intent extra for video

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

 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java    | 10 ++++++----
 1 file changed, 6 insertions(+), 4 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 1802c9e..a1e8827 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -153,6 +153,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     public final static String PLAY_EXTRA_SUBTITLES_LOCATION = "subtitles_location";
     public final static String PLAY_EXTRA_ITEM_TITLE = "title";
     public final static String PLAY_EXTRA_FROM_START = "from_start";
+    public final static String PLAY_EXTRA_START_TIME = "position";
     public final static String PLAY_EXTRA_OPENED_POSITION = "opened_position";
     public final static String PLAY_DISABLE_HARDWARE = "disable_hardware";
 
@@ -2861,10 +2862,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         boolean fromStart = false;
         String itemTitle = null;
         int positionInPlaylist = -1;
-        long savedTime = -1; // position passed in by intent (ms)
         Intent intent = getIntent();
-        String action = intent.getAction();
-        Bundle extras = getIntent().getExtras();
+        Bundle extras = intent.getExtras();
+        long savedTime = extras.getLong(PLAY_EXTRA_START_TIME); // position passed in by intent (ms)
+        if (savedTime == 0l)
+            savedTime = extras.getInt(PLAY_EXTRA_START_TIME);
         /*
          * If the activity has been paused by pressing the power button, then
          * pressing it again will show the lock screen.
@@ -2930,7 +2932,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                 intent.putExtra(PLAY_EXTRA_FROM_START, false);
                 if (fromStart || mService.isPlaying())
                     media.setTime(0l);
-                else
+                else if (savedTime <= 0)
                     savedTime = media.getTime();
 
                 mLastAudioTrack = media.getAudioTrack();



More information about the Android mailing list