summaryrefslogtreecommitdiff
path: root/core/java/android/webkit/HTML5VideoFullScreen.java
diff options
context:
space:
mode:
authorTeng-Hui Zhu <ztenghui@google.com>2012-05-31 17:36:17 -0700
committerTeng-Hui Zhu <ztenghui@google.com>2012-06-27 15:48:02 -0700
commitc3a2858de909145a382e7932d5fb044e1388c0b3 (patch)
tree0f9284cdfd858d7a49e4ee95d805840199e47161 /core/java/android/webkit/HTML5VideoFullScreen.java
parent845b6532b09d4aecb34baa1be66eb53893453c64 (diff)
Avoid redundant reload in inline mode after exit from full screen.
bug:5710646 First, if we exit the full screen mode while playing, we can continue to play in inline mode. If it is paused, then we can avoid a reload if user try to play the same video again after the full screen mode. webkit change: https://android-git.corp.google.com/g/#/c/202138/ Change-Id: Ia69fa22a50d916cd8dd2b995cf3531fe9b637531
Diffstat (limited to 'core/java/android/webkit/HTML5VideoFullScreen.java')
-rw-r--r--core/java/android/webkit/HTML5VideoFullScreen.java41
1 files changed, 18 insertions, 23 deletions
diff --git a/core/java/android/webkit/HTML5VideoFullScreen.java b/core/java/android/webkit/HTML5VideoFullScreen.java
index 33eaad6bde45..b16748b23488 100644
--- a/core/java/android/webkit/HTML5VideoFullScreen.java
+++ b/core/java/android/webkit/HTML5VideoFullScreen.java
@@ -75,7 +75,7 @@ public class HTML5VideoFullScreen extends HTML5VideoView
// ratio is correct.
private int mVideoWidth;
private int mVideoHeight;
-
+ private boolean mPlayingWhenDestroyed = false;
SurfaceHolder.Callback mSHCallback = new SurfaceHolder.Callback()
{
public void surfaceChanged(SurfaceHolder holder, int format,
@@ -101,12 +101,11 @@ public class HTML5VideoFullScreen extends HTML5VideoView
public void surfaceDestroyed(SurfaceHolder holder)
{
- // After we return from this we can't use the surface any more.
- // The current Video View will be destroy when we play a new video.
+ mPlayingWhenDestroyed = mPlayer.isPlaying();
pauseAndDispatch(mProxy);
- // TODO: handle full screen->inline mode transition without a reload.
- mPlayer.release();
- mPlayer = null;
+ // We need to set the display to null before switching into inline
+ // mode to avoid error.
+ mPlayer.setDisplay(null);
mSurfaceHolder = null;
if (mMediaController != null) {
mMediaController.hide();
@@ -194,18 +193,6 @@ public class HTML5VideoFullScreen extends HTML5VideoView
mCanPause = mCanSeekBack = mCanSeekForward = true;
}
- if (mProgressView != null) {
- mProgressView.setVisibility(View.GONE);
- }
-
- mVideoWidth = mp.getVideoWidth();
- mVideoHeight = mp.getVideoHeight();
- // This will trigger the onMeasure to get the display size right.
- mVideoSurfaceView.getHolder().setFixedSize(mVideoWidth, mVideoHeight);
- // Call into the native to ask for the state, if still in play mode,
- // this will trigger the video to play.
- mProxy.dispatchOnRestoreState();
-
if (getStartWhenPrepared()) {
mPlayer.start();
// Clear the flag.
@@ -219,6 +206,16 @@ public class HTML5VideoFullScreen extends HTML5VideoView
mMediaController.setEnabled(true);
mMediaController.show();
}
+
+ if (mProgressView != null) {
+ mProgressView.setVisibility(View.GONE);
+ }
+
+ mVideoWidth = mp.getVideoWidth();
+ mVideoHeight = mp.getVideoHeight();
+ // This will trigger the onMeasure to get the display size right.
+ mVideoSurfaceView.getHolder().setFixedSize(mVideoWidth, mVideoHeight);
+
}
public boolean fullScreenExited() {
@@ -232,7 +229,6 @@ public class HTML5VideoFullScreen extends HTML5VideoView
// which happens when the video view is detached from its parent
// view. This happens in the WebChromeClient before this method
// is invoked.
- mProxy.dispatchOnStopFullScreen();
mLayout.removeView(getSurfaceView());
if (mProgressView != null) {
@@ -242,12 +238,11 @@ public class HTML5VideoFullScreen extends HTML5VideoView
mLayout = null;
// Re enable plugin views.
mProxy.getWebView().getViewManager().showAll();
-
- mProxy = null;
-
// Don't show the controller after exiting the full screen.
mMediaController = null;
- mCurrentState = STATE_RESETTED;
+ // Continue the inline mode playing if necessary.
+ mProxy.dispatchOnStopFullScreen(mPlayingWhenDestroyed);
+ mProxy = null;
}
};