[Android] Keep same mediawrapper loaded

Geoffrey Métais git at videolan.org
Fri May 27 17:54:34 CEST 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri May 27 17:52:57 2016 +0200| [2bc3afe152176237f8fad429d735212f145cb233] | committer: Geoffrey Métais

Keep same mediawrapper loaded

Fixes subtitles tracks lost on apps switch

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

 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java   | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 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 55374e8..a782a68 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -869,7 +869,10 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             time = 0;
         else
             time -= 2000; // go back 2 seconds, to compensate loading time
-        mService.stop();
+        if (isFinishing())
+            mService.stop();
+        else
+            mService.pause();
 
         SharedPreferences.Editor editor = mSettings.edit();
         // Save position
@@ -2935,8 +2938,10 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             mService.addCallback(this);
             /* prepare playback */
             boolean hasMedia = mService.hasMedia();
-            if (media == null)
-                media = hasMedia ? mService.getCurrentMediaWrapper() : new MediaWrapper(mUri);
+            if (hasMedia)
+                media = mService.getCurrentMediaWrapper();
+            else if (media == null)
+                media = new MediaWrapper(mUri);
             if (mWasPaused)
                 media.addFlags(MediaWrapper.MEDIA_PAUSED);
             if (mHardwareAccelerationError || intent.hasExtra(PLAY_DISABLE_HARDWARE))



More information about the Android mailing list