diff options
| author | Teng-Hui Zhu <ztenghui@google.com> | 2012-05-09 14:13:52 -0700 |
|---|---|---|
| committer | Teng-Hui Zhu <ztenghui@google.com> | 2012-05-10 16:46:51 -0700 |
| commit | c2b06d5a83f8f118eaf46f093126da08a28715eb (patch) | |
| tree | a5c9bd0cebb44c77d228828de76080aa793074f6 /core/java/android/webkit/HTML5VideoViewProxy.java | |
| parent | f4c77df0593c1bb81dd5ee04ee415a8cf3bd37bb (diff) | |
Avoid inline->fullscreen reload for html5 video.
Now when a user start inline play and then switch to full screen, there is no
reload any more.
Basically, we change mediaplayer as a static member, and detect possible
situation to skip the prepare work.
bug:5710646
Change-Id: Ida34cf2e919a6cc8e0d52cd1175d51b5f5d527f7
Diffstat (limited to 'core/java/android/webkit/HTML5VideoViewProxy.java')
| -rw-r--r-- | core/java/android/webkit/HTML5VideoViewProxy.java | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/core/java/android/webkit/HTML5VideoViewProxy.java b/core/java/android/webkit/HTML5VideoViewProxy.java index 5fa4badda334..a17cb51a2a85 100644 --- a/core/java/android/webkit/HTML5VideoViewProxy.java +++ b/core/java/android/webkit/HTML5VideoViewProxy.java @@ -112,13 +112,14 @@ class HTML5VideoViewProxy extends Handler mBaseLayer = layer; int currentVideoLayerId = mHTML5VideoView.getVideoLayerId(); - SurfaceTexture surfTexture = mHTML5VideoView.getSurfaceTexture(currentVideoLayerId); + SurfaceTexture surfTexture = + HTML5VideoInline.getSurfaceTexture(currentVideoLayerId); int textureName = mHTML5VideoView.getTextureName(); if (layer != 0 && surfTexture != null && currentVideoLayerId != -1) { int playerState = mHTML5VideoView.getCurrentState(); if (mHTML5VideoView.getPlayerBuffering()) - playerState = HTML5VideoView.STATE_NOTPREPARED; + playerState = HTML5VideoView.STATE_PREPARING; boolean foundInTree = nativeSendSurfaceTexture(surfTexture, layer, currentVideoLayerId, textureName, playerState); @@ -145,6 +146,7 @@ class HTML5VideoViewProxy extends Handler HTML5VideoViewProxy proxy, WebViewClassic webView) { // Save the inline video info and inherit it in the full screen int savePosition = 0; + boolean canSkipPrepare = false; if (mHTML5VideoView != null) { // We don't allow enter full screen mode while the previous // full screen video hasn't finished yet. @@ -156,15 +158,20 @@ class HTML5VideoViewProxy extends Handler // save the current position. if (layerId == mHTML5VideoView.getVideoLayerId()) { savePosition = mHTML5VideoView.getCurrentPosition(); + int playerState = mHTML5VideoView.getCurrentState(); + canSkipPrepare = (playerState == HTML5VideoView.STATE_PREPARING + || playerState == HTML5VideoView.STATE_PREPARED + || playerState == HTML5VideoView.STATE_PLAYING) + && !mHTML5VideoView.isFullScreenMode(); + } + if (!canSkipPrepare) { + mHTML5VideoView.reset(); } - mHTML5VideoView.release(); } mHTML5VideoView = new HTML5VideoFullScreen(proxy.getContext(), - layerId, savePosition); + layerId, savePosition, canSkipPrepare); mCurrentProxy = proxy; - mHTML5VideoView.setVideoURI(url, mCurrentProxy); - mHTML5VideoView.enterFullScreenVideoState(layerId, proxy, webView); } @@ -217,8 +224,7 @@ class HTML5VideoViewProxy extends Handler if (!backFromFullScreenMode) { mHTML5VideoView.pauseAndDispatch(mCurrentProxy); } - // release the media player to avoid finalize error - mHTML5VideoView.release(); + mHTML5VideoView.reset(); } mCurrentProxy = proxy; mHTML5VideoView = new HTML5VideoInline(videoLayerId, time); |
