Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java

Issue 147373004: Force landscape rotation of full-screen HTML5 video on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java b/content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java
index a1c2f1492ec1b3c39295bfac80f6b53c224d5767..a0c7692f4a6a1fd6e2d6bd07864dacef28236e49 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java
@@ -5,9 +5,11 @@
package org.chromium.content.browser;
import android.app.Activity;
+import android.content.pm.ActivityInfo;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
+import android.graphics.Point;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
@@ -77,6 +79,8 @@ public class ContentVideoView extends FrameLayout implements SurfaceHolder.Callb
private String mErrorTitle;
private String mVideoLoadingText;
+ private int mSavedOrientation;
+ private boolean mRotated;
// This view will contain the video.
private VideoSurfaceView mVideoSurfaceView;
@@ -159,6 +163,14 @@ public class ContentVideoView extends FrameLayout implements SurfaceHolder.Callb
}
protected void showContentVideoView() {
+ Activity a = (Activity) getContext();
+ Point displaySize = new Point();
+ a.getWindowManager().getDefaultDisplay().getSize(displaySize);
+ if (displaySize.y > displaySize.x) {
+ mSavedOrientation = a.getRequestedOrientation();
+ a.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
philipj_slow 2014/01/29 13:02:50 SCREEN_ORIENTATION_USER_LANDSCAPE is probably the
+ mRotated = true;
+ }
mVideoSurfaceView.getHolder().addCallback(this);
this.addView(mVideoSurfaceView, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
@@ -386,6 +398,13 @@ public class ContentVideoView extends FrameLayout implements SurfaceHolder.Callb
nativeExitFullscreen(mNativeContentVideoView, relaseMediaPlayer);
mNativeContentVideoView = 0;
}
+
+ if (mRotated) {
+ Activity a = (Activity) getContext();
+ a.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
philipj_slow 2014/01/29 13:02:50 This line should be removed, it's overridden immed
+ a.setRequestedOrientation(mSavedOrientation);
+ mRotated = false;
+ }
}
@CalledByNative
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698