[Android] VideoPlayer: fix handleHardwareAccelerationError

Thomas Guillem git at videolan.org
Wed Dec 2 18:43:12 CET 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Dec  2 18:41:10 2015 +0100| [4cd30fcbf9f5c3190b1545a8c0b05156e12333ef] | committer: Thomas Guillem

VideoPlayer: fix handleHardwareAccelerationError

loadMedia was messing with current state and could cause a NPE.
Directly restart using mService and seek at previous position.

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

 .../org/videolan/vlc/gui/video/VideoPlayerActivity.java |   15 ++++++++++++---
 1 file changed, 12 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 1b98dd4..8862b46 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1577,11 +1577,20 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         if (mSwitchingView)
             return;
         Toast.makeText(this, R.string.hardware_acceleration_error, Toast.LENGTH_LONG).show();
-        mService.removeCallback(this);
+        final boolean wasPaused = !mService.isPlaying();
+        final long oldTime = mService.getTime();
         mService.stop();
-        if(!isFinishing())
-            loadMedia();
+        if(!isFinishing()) {
+            final MediaWrapper mw = new MediaWrapper(mUri);
+            if (wasPaused)
+                mw.addFlags(MediaWrapper.MEDIA_PAUSED);
+            mw.addFlags(MediaWrapper.MEDIA_NO_HWACCEL);
+            mw.addFlags(MediaWrapper.MEDIA_VIDEO);
+            mService.load(mw);
+            if (oldTime > 0)
+                seek(oldTime);
         }
+    }
 
     private void handleVout(int voutCount) {
         final IVLCVout vlcVout = mService.getVLCVout();



More information about the Android mailing list