// Every time webView setBaseLayer, this will be called. // 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) { // Don't do this for full screen mode. if (mHTML5VideoView != null && !mHTML5VideoView.isFullScreenMode() && !mHTML5VideoView.isReleased()) { int currentVideoLayerId = mHTML5VideoView.getVideoLayerId(); 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_PREPARING; boolean foundInTree = nativeSendSurfaceTexture( surfTexture, layer, currentVideoLayerId, textureName, playerState); if (playerState >= HTML5VideoView.STATE_PREPARED && !foundInTree) { mHTML5VideoView.pauseAndDispatch(mCurrentProxy); } } } }
public static void enterFullScreenVideo( int layerId, String url, HTML5VideoViewProxy proxy, WebViewClassic webView) { // Save the inline video info and inherit it in the full screen int savePosition = 0; boolean canSkipPrepare = false; boolean forceStart = false; if (mHTML5VideoView != null) { // We don't allow enter full screen mode while the previous // full screen video hasn't finished yet. if (!mHTML5VideoView.fullScreenExited() && mHTML5VideoView.isFullScreenMode()) { Log.w(LOGTAG, "Try to reenter the full screen mode"); return; } int playerState = mHTML5VideoView.getCurrentState(); // If we are playing the same video, then it is better to // save the current position. if (layerId == mHTML5VideoView.getVideoLayerId()) { savePosition = mHTML5VideoView.getCurrentPosition(); canSkipPrepare = (playerState == HTML5VideoView.STATE_PREPARING || playerState == HTML5VideoView.STATE_PREPARED || playerState == HTML5VideoView.STATE_PLAYING) && !mHTML5VideoView.isFullScreenMode(); } if (!canSkipPrepare) { mHTML5VideoView.reset(); } else { forceStart = playerState == HTML5VideoView.STATE_PREPARING || playerState == HTML5VideoView.STATE_PLAYING; } } mHTML5VideoView = new HTML5VideoFullScreen(proxy.getContext(), layerId, savePosition, canSkipPrepare); mHTML5VideoView.setStartWhenPrepared(forceStart); mCurrentProxy = proxy; mHTML5VideoView.setVideoURI(url, mCurrentProxy); mHTML5VideoView.enterFullScreenVideoState(layerId, proxy, webView); }