[Android] Set custom video player rotation animation

Geoffrey Métais git at videolan.org
Wed May 2 15:19:11 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed May  2 15:18:36 2018 +0200| [85df54a27a0b5c446f4f372e7a35437f20cce0da] | committer: Geoffrey Métais

Set custom video player rotation animation

Improves activity rotation, by preventing image freeze

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

 .../org/videolan/vlc/gui/video/VideoPlayerActivity.java    | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

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 9a07dc2e9..6f7e2a9d2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -81,6 +81,7 @@ import android.view.View.OnClickListener;
 import android.view.View.OnLayoutChangeListener;
 import android.view.ViewGroup;
 import android.view.ViewGroup.LayoutParams;
+import android.view.Window;
 import android.view.WindowManager;
 import android.view.animation.Animation;
 import android.view.animation.AnimationSet;
@@ -446,6 +447,19 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             final ScreenConfig sc = new ScreenConfig(dm, xRange, yRange, mCurrentScreenOrientation);
             mTouchDelegate = new VideoTouchDelegate(this, touch, sc, isRtl);
         }
+        setRotationAnimation();
+    }
+
+    /*
+    Improves activity rotation, by preventing image freeze.
+     */
+    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
+    private void setRotationAnimation() {
+        if (!AndroidUtil.isJellyBeanMR2OrLater) return;
+        final Window win = getWindow();
+        final WindowManager.LayoutParams winParams = win.getAttributes();
+        winParams.rotationAnimation = AndroidUtil.isOOrLater ? WindowManager.LayoutParams.ROTATION_ANIMATION_ROTATE : WindowManager.LayoutParams.ROTATION_ANIMATION_JUMPCUT;
+        win.setAttributes(winParams);
     }
 
     @Override



More information about the Android mailing list