Loading core/java/android/webkit/HTML5VideoFullScreen.java +18 −23 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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(); Loading Loading @@ -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. Loading @@ -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() { Loading @@ -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) { Loading @@ -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; } }; Loading core/java/android/webkit/HTML5VideoInline.java +6 −4 Original line number Diff line number Diff line Loading @@ -34,8 +34,8 @@ public class HTML5VideoInline extends HTML5VideoView{ } } HTML5VideoInline(int videoLayerId, int position) { init(videoLayerId, position, false); HTML5VideoInline(int videoLayerId, int position, boolean skipPrepare) { init(videoLayerId, position, skipPrepare); } @Override Loading Loading @@ -84,7 +84,7 @@ public class HTML5VideoInline extends HTML5VideoView{ return mSurfaceTexture; } public boolean surfaceTextureDeleted() { public static boolean surfaceTextureDeleted() { return (mSurfaceTexture == null); } Loading @@ -110,7 +110,9 @@ public class HTML5VideoInline extends HTML5VideoView{ } private void setFrameAvailableListener(SurfaceTexture.OnFrameAvailableListener l) { if (mSurfaceTexture != null) { mSurfaceTexture.setOnFrameAvailableListener(l); } } } core/java/android/webkit/HTML5VideoView.java +0 −5 Original line number Diff line number Diff line Loading @@ -337,11 +337,6 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener { // Only used in HTML5VideoFullScreen } public boolean surfaceTextureDeleted() { // Only meaningful for HTML5VideoInline return false; } public boolean fullScreenExited() { // Only meaningful for HTML5VideoFullScreen return false; Loading core/java/android/webkit/HTML5VideoViewProxy.java +46 −18 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ class HTML5VideoViewProxy extends Handler private static final int LOAD_DEFAULT_POSTER = 104; private static final int BUFFERING_START = 105; private static final int BUFFERING_END = 106; private static final int ENTER_FULLSCREEN = 107; // Message Ids to be handled on the WebCore thread private static final int PREPARED = 200; Loading Loading @@ -105,12 +106,10 @@ class HTML5VideoViewProxy extends Handler // When we found the Video layer, then we set the Surface Texture to it. // Otherwise, we may want to delete the Surface Texture to save memory. public static void setBaseLayer(int layer) { mBaseLayer = layer; // Don't do this for full screen mode. if (mHTML5VideoView != null && !mHTML5VideoView.isFullScreenMode() && !mHTML5VideoView.surfaceTextureDeleted()) { mBaseLayer = layer; && !mHTML5VideoView.isFullScreenMode()) { int currentVideoLayerId = mHTML5VideoView.getVideoLayerId(); SurfaceTexture surfTexture = HTML5VideoInline.getSurfaceTexture(currentVideoLayerId); Loading @@ -126,7 +125,6 @@ class HTML5VideoViewProxy extends Handler if (playerState >= HTML5VideoView.STATE_PREPARED && !foundInTree) { mHTML5VideoView.pauseAndDispatch(mCurrentProxy); mHTML5VideoView.deleteSurfaceTexture(); } } } Loading @@ -136,9 +134,6 @@ class HTML5VideoViewProxy extends Handler public static void pauseAndDispatch() { if (mHTML5VideoView != null) { mHTML5VideoView.pauseAndDispatch(mCurrentProxy); // When switching out, clean the video content on the old page // by telling the layer not readyToUseSurfTex. setBaseLayer(mBaseLayer); } } Loading Loading @@ -217,9 +212,14 @@ class HTML5VideoViewProxy extends Handler } } if (backFromFullScreenMode boolean skipPrepare = false; boolean createInlineView = false; if (backFromFullScreenMode && currentVideoLayerId == videoLayerId) { skipPrepare = true; createInlineView = true; } else if(backFromFullScreenMode || currentVideoLayerId != videoLayerId || mHTML5VideoView.surfaceTextureDeleted()) { || HTML5VideoInline.surfaceTextureDeleted()) { // Here, we handle the case when switching to a new video, // either inside a WebView or across WebViews // For switching videos within a WebView or across the WebView, Loading @@ -231,12 +231,18 @@ class HTML5VideoViewProxy extends Handler } mHTML5VideoView.reset(); } createInlineView = true; } if (createInlineView) { mCurrentProxy = proxy; mHTML5VideoView = new HTML5VideoInline(videoLayerId, time); mHTML5VideoView = new HTML5VideoInline(videoLayerId, time, skipPrepare); mHTML5VideoView.setVideoURI(url, mCurrentProxy); mHTML5VideoView.prepareDataAndDisplayMode(proxy); } else if (mCurrentProxy == proxy) { return; } if (mCurrentProxy == proxy) { // Here, we handle the case when we keep playing with one video if (!mHTML5VideoView.isPlaying()) { mHTML5VideoView.seekTo(time); Loading Loading @@ -278,9 +284,6 @@ class HTML5VideoViewProxy extends Handler if (!mHTML5VideoView.isFullScreenMode()) { mHTML5VideoView.start(); } if (mBaseLayer != 0) { setBaseLayer(mBaseLayer); } } public static void end() { Loading Loading @@ -333,8 +336,9 @@ class HTML5VideoViewProxy extends Handler mWebCoreHandler.sendMessage(msg); } public void dispatchOnStopFullScreen() { public void dispatchOnStopFullScreen(boolean stillPlaying) { Message msg = Message.obtain(mWebCoreHandler, STOPFULLSCREEN); msg.arg1 = stillPlaying ? 1 : 0; mWebCoreHandler.sendMessage(msg); } Loading Loading @@ -369,6 +373,15 @@ class HTML5VideoViewProxy extends Handler } break; } case ENTER_FULLSCREEN:{ String url = (String) msg.obj; WebChromeClient client = mWebView.getWebChromeClient(); int videoLayerID = msg.arg1; if (client != null) { VideoPlayer.enterFullScreenVideo(videoLayerID, url, this, mWebView); } break; } case SEEK: { Integer time = (Integer) msg.obj; mSeekPosition = time; Loading Loading @@ -613,7 +626,7 @@ class HTML5VideoViewProxy extends Handler nativeOnTimeupdate(msg.arg1, mNativePointer); break; case STOPFULLSCREEN: nativeOnStopFullscreen(mNativePointer); nativeOnStopFullscreen(msg.arg1, mNativePointer); break; case RESTORESTATE: nativeOnRestoreState(mNativePointer); Loading Loading @@ -663,6 +676,21 @@ class HTML5VideoViewProxy extends Handler sendMessage(message); } /** * Play a video stream in full screen mode. * @param url is the URL of the video stream. */ public void enterFullscreenForVideoLayer(String url, int videoLayerID) { if (url == null) { return; } Message message = obtainMessage(ENTER_FULLSCREEN); message.arg1 = videoLayerID; message.obj = url; sendMessage(message); } /** * Seek into the video stream. * @param time is the position in the video stream. Loading Loading @@ -748,7 +776,7 @@ class HTML5VideoViewProxy extends Handler private native void nativeOnPaused(int nativePointer); private native void nativeOnPosterFetched(Bitmap poster, int nativePointer); private native void nativeOnTimeupdate(int position, int nativePointer); private native void nativeOnStopFullscreen(int nativePointer); private native void nativeOnStopFullscreen(int stillPlaying, int nativePointer); private native void nativeOnRestoreState(int nativePointer); private native static boolean nativeSendSurfaceTexture(SurfaceTexture texture, int baseLayer, int videoLayerId, int textureName, Loading core/java/android/webkit/WebViewClassic.java +1 −12 Original line number Diff line number Diff line Loading @@ -743,12 +743,11 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc // the existing GL resources for the html5 video will be destroyed // at native side. // Here we just need to clean up the Surface Texture which is static. if (level >= TRIM_MEMORY_UI_HIDDEN) { if (level > TRIM_MEMORY_UI_HIDDEN) { HTML5VideoInline.cleanupSurfaceTexture(); } WebViewClassic.nativeOnTrimMemory(level); } } // A final CallbackProxy shared by WebViewCore and BrowserFrame. Loading Loading @@ -1037,7 +1036,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc static final int AUTOFILL_COMPLETE = 134; static final int SCREEN_ON = 136; static final int ENTER_FULLSCREEN_VIDEO = 137; static final int UPDATE_ZOOM_DENSITY = 139; static final int EXIT_FULLSCREEN_VIDEO = 140; Loading Loading @@ -7365,15 +7363,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc mWebView.setKeepScreenOn(msg.arg1 == 1); break; case ENTER_FULLSCREEN_VIDEO: int layerId = msg.arg1; String url = (String) msg.obj; if (mHTML5VideoViewProxy != null) { mHTML5VideoViewProxy.enterFullScreenVideo(layerId, url); } break; case EXIT_FULLSCREEN_VIDEO: if (mHTML5VideoViewProxy != null) { mHTML5VideoViewProxy.exitFullScreenVideo(); Loading Loading
core/java/android/webkit/HTML5VideoFullScreen.java +18 −23 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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(); Loading Loading @@ -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. Loading @@ -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() { Loading @@ -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) { Loading @@ -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; } }; Loading
core/java/android/webkit/HTML5VideoInline.java +6 −4 Original line number Diff line number Diff line Loading @@ -34,8 +34,8 @@ public class HTML5VideoInline extends HTML5VideoView{ } } HTML5VideoInline(int videoLayerId, int position) { init(videoLayerId, position, false); HTML5VideoInline(int videoLayerId, int position, boolean skipPrepare) { init(videoLayerId, position, skipPrepare); } @Override Loading Loading @@ -84,7 +84,7 @@ public class HTML5VideoInline extends HTML5VideoView{ return mSurfaceTexture; } public boolean surfaceTextureDeleted() { public static boolean surfaceTextureDeleted() { return (mSurfaceTexture == null); } Loading @@ -110,7 +110,9 @@ public class HTML5VideoInline extends HTML5VideoView{ } private void setFrameAvailableListener(SurfaceTexture.OnFrameAvailableListener l) { if (mSurfaceTexture != null) { mSurfaceTexture.setOnFrameAvailableListener(l); } } }
core/java/android/webkit/HTML5VideoView.java +0 −5 Original line number Diff line number Diff line Loading @@ -337,11 +337,6 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener { // Only used in HTML5VideoFullScreen } public boolean surfaceTextureDeleted() { // Only meaningful for HTML5VideoInline return false; } public boolean fullScreenExited() { // Only meaningful for HTML5VideoFullScreen return false; Loading
core/java/android/webkit/HTML5VideoViewProxy.java +46 −18 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ class HTML5VideoViewProxy extends Handler private static final int LOAD_DEFAULT_POSTER = 104; private static final int BUFFERING_START = 105; private static final int BUFFERING_END = 106; private static final int ENTER_FULLSCREEN = 107; // Message Ids to be handled on the WebCore thread private static final int PREPARED = 200; Loading Loading @@ -105,12 +106,10 @@ class HTML5VideoViewProxy extends Handler // When we found the Video layer, then we set the Surface Texture to it. // Otherwise, we may want to delete the Surface Texture to save memory. public static void setBaseLayer(int layer) { mBaseLayer = layer; // Don't do this for full screen mode. if (mHTML5VideoView != null && !mHTML5VideoView.isFullScreenMode() && !mHTML5VideoView.surfaceTextureDeleted()) { mBaseLayer = layer; && !mHTML5VideoView.isFullScreenMode()) { int currentVideoLayerId = mHTML5VideoView.getVideoLayerId(); SurfaceTexture surfTexture = HTML5VideoInline.getSurfaceTexture(currentVideoLayerId); Loading @@ -126,7 +125,6 @@ class HTML5VideoViewProxy extends Handler if (playerState >= HTML5VideoView.STATE_PREPARED && !foundInTree) { mHTML5VideoView.pauseAndDispatch(mCurrentProxy); mHTML5VideoView.deleteSurfaceTexture(); } } } Loading @@ -136,9 +134,6 @@ class HTML5VideoViewProxy extends Handler public static void pauseAndDispatch() { if (mHTML5VideoView != null) { mHTML5VideoView.pauseAndDispatch(mCurrentProxy); // When switching out, clean the video content on the old page // by telling the layer not readyToUseSurfTex. setBaseLayer(mBaseLayer); } } Loading Loading @@ -217,9 +212,14 @@ class HTML5VideoViewProxy extends Handler } } if (backFromFullScreenMode boolean skipPrepare = false; boolean createInlineView = false; if (backFromFullScreenMode && currentVideoLayerId == videoLayerId) { skipPrepare = true; createInlineView = true; } else if(backFromFullScreenMode || currentVideoLayerId != videoLayerId || mHTML5VideoView.surfaceTextureDeleted()) { || HTML5VideoInline.surfaceTextureDeleted()) { // Here, we handle the case when switching to a new video, // either inside a WebView or across WebViews // For switching videos within a WebView or across the WebView, Loading @@ -231,12 +231,18 @@ class HTML5VideoViewProxy extends Handler } mHTML5VideoView.reset(); } createInlineView = true; } if (createInlineView) { mCurrentProxy = proxy; mHTML5VideoView = new HTML5VideoInline(videoLayerId, time); mHTML5VideoView = new HTML5VideoInline(videoLayerId, time, skipPrepare); mHTML5VideoView.setVideoURI(url, mCurrentProxy); mHTML5VideoView.prepareDataAndDisplayMode(proxy); } else if (mCurrentProxy == proxy) { return; } if (mCurrentProxy == proxy) { // Here, we handle the case when we keep playing with one video if (!mHTML5VideoView.isPlaying()) { mHTML5VideoView.seekTo(time); Loading Loading @@ -278,9 +284,6 @@ class HTML5VideoViewProxy extends Handler if (!mHTML5VideoView.isFullScreenMode()) { mHTML5VideoView.start(); } if (mBaseLayer != 0) { setBaseLayer(mBaseLayer); } } public static void end() { Loading Loading @@ -333,8 +336,9 @@ class HTML5VideoViewProxy extends Handler mWebCoreHandler.sendMessage(msg); } public void dispatchOnStopFullScreen() { public void dispatchOnStopFullScreen(boolean stillPlaying) { Message msg = Message.obtain(mWebCoreHandler, STOPFULLSCREEN); msg.arg1 = stillPlaying ? 1 : 0; mWebCoreHandler.sendMessage(msg); } Loading Loading @@ -369,6 +373,15 @@ class HTML5VideoViewProxy extends Handler } break; } case ENTER_FULLSCREEN:{ String url = (String) msg.obj; WebChromeClient client = mWebView.getWebChromeClient(); int videoLayerID = msg.arg1; if (client != null) { VideoPlayer.enterFullScreenVideo(videoLayerID, url, this, mWebView); } break; } case SEEK: { Integer time = (Integer) msg.obj; mSeekPosition = time; Loading Loading @@ -613,7 +626,7 @@ class HTML5VideoViewProxy extends Handler nativeOnTimeupdate(msg.arg1, mNativePointer); break; case STOPFULLSCREEN: nativeOnStopFullscreen(mNativePointer); nativeOnStopFullscreen(msg.arg1, mNativePointer); break; case RESTORESTATE: nativeOnRestoreState(mNativePointer); Loading Loading @@ -663,6 +676,21 @@ class HTML5VideoViewProxy extends Handler sendMessage(message); } /** * Play a video stream in full screen mode. * @param url is the URL of the video stream. */ public void enterFullscreenForVideoLayer(String url, int videoLayerID) { if (url == null) { return; } Message message = obtainMessage(ENTER_FULLSCREEN); message.arg1 = videoLayerID; message.obj = url; sendMessage(message); } /** * Seek into the video stream. * @param time is the position in the video stream. Loading Loading @@ -748,7 +776,7 @@ class HTML5VideoViewProxy extends Handler private native void nativeOnPaused(int nativePointer); private native void nativeOnPosterFetched(Bitmap poster, int nativePointer); private native void nativeOnTimeupdate(int position, int nativePointer); private native void nativeOnStopFullscreen(int nativePointer); private native void nativeOnStopFullscreen(int stillPlaying, int nativePointer); private native void nativeOnRestoreState(int nativePointer); private native static boolean nativeSendSurfaceTexture(SurfaceTexture texture, int baseLayer, int videoLayerId, int textureName, Loading
core/java/android/webkit/WebViewClassic.java +1 −12 Original line number Diff line number Diff line Loading @@ -743,12 +743,11 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc // the existing GL resources for the html5 video will be destroyed // at native side. // Here we just need to clean up the Surface Texture which is static. if (level >= TRIM_MEMORY_UI_HIDDEN) { if (level > TRIM_MEMORY_UI_HIDDEN) { HTML5VideoInline.cleanupSurfaceTexture(); } WebViewClassic.nativeOnTrimMemory(level); } } // A final CallbackProxy shared by WebViewCore and BrowserFrame. Loading Loading @@ -1037,7 +1036,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc static final int AUTOFILL_COMPLETE = 134; static final int SCREEN_ON = 136; static final int ENTER_FULLSCREEN_VIDEO = 137; static final int UPDATE_ZOOM_DENSITY = 139; static final int EXIT_FULLSCREEN_VIDEO = 140; Loading Loading @@ -7365,15 +7363,6 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc mWebView.setKeepScreenOn(msg.arg1 == 1); break; case ENTER_FULLSCREEN_VIDEO: int layerId = msg.arg1; String url = (String) msg.obj; if (mHTML5VideoViewProxy != null) { mHTML5VideoViewProxy.enterFullScreenVideo(layerId, url); } break; case EXIT_FULLSCREEN_VIDEO: if (mHTML5VideoViewProxy != null) { mHTML5VideoViewProxy.exitFullScreenVideo(); Loading