[Android] Set custom video player rotation animation

Geoffrey Métais git at videolan.org
Wed May 2 16:48:01 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed May  2 15:18:36 2018 +0200| [c9214156b92dd3ebc9dbfba97e94b5920f06b1a5] | 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/c9214156b92dd3ebc9dbfba97e94b5920f06b1a5
---

 vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java     | 11 +++++++++++
 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java   |  1 +
 2 files changed, 12 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java b/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
index 4db7c9cb8..204dcb0a4 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
@@ -59,6 +59,8 @@ import android.view.DragEvent;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
 import android.view.animation.Animation;
 import android.view.animation.AnimationSet;
 import android.view.animation.DecelerateInterpolator;
@@ -446,4 +448,13 @@ public class UiTools {
             }
         });
     }
+
+    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
+    public static void setRotationAnimation(Activity activity) {
+        if (!AndroidUtil.isJellyBeanMR2OrLater) return;
+        final Window win = activity.getWindow();
+        final WindowManager.LayoutParams winParams = win.getAttributes();
+        winParams.rotationAnimation = AndroidUtil.isOOrLater ? WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS : WindowManager.LayoutParams.ROTATION_ANIMATION_JUMPCUT;
+        win.setAttributes(winParams);
+    }
 }
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..498a644b8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -446,6 +446,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             final ScreenConfig sc = new ScreenConfig(dm, xRange, yRange, mCurrentScreenOrientation);
             mTouchDelegate = new VideoTouchDelegate(this, touch, sc, isRtl);
         }
+        UiTools.setRotationAnimation(this);
     }
 
     @Override



More information about the Android mailing list