[Android] VideoPlayer: fix IllegalStateException in Awindow
Thomas Guillem
git at videolan.org
Mon Oct 12 15:46:20 CEST 2015
vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Oct 12 13:45:31 2015 +0200| [9fa016704ba73e6c3c4bcdf8fe08c121147123df] | committer: Jean-Baptiste Kempf
VideoPlayer: fix IllegalStateException in Awindow
This may happen when a new VideoPlayer activity is started while a previous is
not yet stopped.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=9fa016704ba73e6c3c4bcdf8fe08c121147123df
---
.../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
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 2a573e6..9b3eeda 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -287,6 +287,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
* (e.g. lock screen, or to restore the pause state)
*/
private boolean mPlaybackStarted = false;
+ private boolean mSurfacesAttached = false;
// Tips
private View mOverlayTips;
@@ -699,6 +700,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
LibVLC().setOnHardwareAccelerationError(this);
final IVLCVout vlcVout = mService.getVLCVout();
+ vlcVout.detachViews();
if (mPresentation == null) {
vlcVout.setVideoView(mSurfaceView);
if (mSubtitlesSurfaceView.getVisibility() != View.GONE)
@@ -708,6 +710,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
if (mSubtitlesSurfaceView.getVisibility() != View.GONE)
vlcVout.setSubtitlesView(mPresentation.mSubtitlesSurfaceView);
}
+ mSurfacesAttached = true;
vlcVout.addCallback(this);
vlcVout.attachViews();
mSurfaceView.setKeepScreenOn(true);
@@ -741,7 +744,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mService.removeCallback(this);
final IVLCVout vlcVout = mService.getVLCVout();
vlcVout.removeCallback(this);
- vlcVout.detachViews();
+ if (mSurfacesAttached)
+ vlcVout.detachViews();
mSurfaceView.setKeepScreenOn(false);
mHandler.removeCallbacksAndMessages(null);
@@ -3055,5 +3059,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
@Override
public void onSurfacesDestroyed(IVLCVout vlcVout) {
+ mSurfacesAttached = false;
}
}
More information about the Android
mailing list