[Android] VideoPlayerActivity: ensure views are detached before attaching new ones

Thomas Guillem git at videolan.org
Wed Jul 13 11:45:57 CEST 2016


vlc-android | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Jul 13 11:45:05 2016 +0200| [21603a2a35952b74d3bda5d23b5ef9cf37fef266] | committer: Thomas Guillem

VideoPlayerActivity: ensure views are detached before attaching new ones

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

 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java       | 8 ++------
 1 file changed, 2 insertions(+), 6 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 e77927b..8b17d49 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -320,7 +320,6 @@ 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;
@@ -747,6 +746,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         final IVLCVout vlcVout = mService.getVLCVout();
         if (vlcVout.areViewsAttached() && mService.isPlayingPopup())
             mService.stopPlayback();
+        vlcVout.detachViews();
         if (mPresentation == null) {
             vlcVout.setVideoView(mSurfaceView);
             if (mSubtitlesSurfaceView.getVisibility() != View.GONE)
@@ -756,7 +756,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             if (mSubtitlesSurfaceView.getVisibility() != View.GONE)
                 vlcVout.setSubtitlesView(mPresentation.mSubtitlesSurfaceView);
         }
-        mSurfacesAttached = true;
         vlcVout.addCallback(this);
         vlcVout.attachViews();
         mService.setVideoTrackEnabled(true);
@@ -859,8 +858,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         mHandler.removeCallbacksAndMessages(null);
         final IVLCVout vlcVout = mService.getVLCVout();
         vlcVout.removeCallback(this);
-        if (mSurfacesAttached)
-            vlcVout.detachViews();
+        vlcVout.detachViews();
 
         if(mSwitchingView && mService != null) {
             Log.d(TAG, "mLocation = \"" + mUri + "\"");
@@ -1873,7 +1871,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         SurfaceView surface;
         SurfaceView subtitlesSurface;
         FrameLayout surfaceFrame;
-
         if (mPresentation == null) {
             surface = mSurfaceView;
             subtitlesSurface = mSubtitlesSurfaceView;
@@ -3446,7 +3443,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
 
     @Override
     public void onSurfacesDestroyed(IVLCVout vlcVout) {
-        mSurfacesAttached = false;
     }
 
     @Override



More information about the Android mailing list