public static void exitFullScreenVideo(HTML5VideoViewProxy proxy, WebViewClassic webView) { if (!mHTML5VideoView.fullScreenExited() && mHTML5VideoView.isFullScreenMode()) { WebChromeClient client = webView.getWebChromeClient(); if (client != null) { client.onHideCustomView(); } } }
public void show() { if (!getControls().isVisible() && !mZoomManager.isZoomScaleFixed()) { mZoomButtonsController.setVisible(true); if (mZoomManager.isDoubleTapEnabled()) { WebSettingsClassic settings = mWebView.getSettings(); int count = settings.getDoubleTapToastCount(); if (mZoomManager.isInZoomOverview() && count > 0) { settings.setDoubleTapToastCount(--count); Toast.makeText( mWebView.getContext(), com.android.internal.R.string.double_tap_toast, Toast.LENGTH_LONG) .show(); } } } }
/** * Private constructor. * * @param webView is the WebView that hosts the video. * @param nativePtr is the C++ pointer to the MediaPlayerPrivate object. */ private HTML5VideoViewProxy(WebViewClassic webView, int nativePtr) { // This handler is for the main (UI) thread. super(Looper.getMainLooper()); // Save the WebView object. mWebView = webView; // Pass Proxy into webview, such that every time we have a setBaseLayer // call, we tell this Proxy to call the native to update the layer tree // for the Video Layer's surface texture info mWebView.setHTML5VideoViewProxy(this); // Save the native ptr mNativePointer = nativePtr; // create the message handler for this thread createWebCoreHandler(); }
private ZoomButtonsController getControls() { if (mZoomButtonsController == null) { mZoomButtonsController = new ZoomButtonsController(mWebView.getWebView()); mZoomButtonsController.setOnZoomListener(new ZoomListener()); // ZoomButtonsController positions the buttons at the bottom, but in // the middle. Change their layout parameters so they appear on the // right. View controls = mZoomButtonsController.getZoomControls(); ViewGroup.LayoutParams params = controls.getLayoutParams(); if (params instanceof FrameLayout.LayoutParams) { ((FrameLayout.LayoutParams) params).gravity = Gravity.RIGHT; } } return mZoomButtonsController; }
public Context getContext() { return mWebView.getContext(); }
// Handler for the messages from WebCore or Timer thread to the UI thread. @Override public void handleMessage(Message msg) { // This executes on the UI thread. Xlog.d(XLOGTAG, "handleMessage::msg.what is: " + msg.what + this); switch (msg.what) { case PLAY: { String url = (String) msg.obj; WebChromeClient client = mWebView.getWebChromeClient(); int videoLayerID = msg.arg1; if (client != null) { VideoPlayer.play(url, mSeekPosition, this, client, videoLayerID); } 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; VideoPlayer.seek(mSeekPosition, this); break; } case PAUSE: { VideoPlayer.pause(this); break; } case ENDED: if (msg.arg1 == 1) VideoPlayer.isVideoSelfEnded = true; VideoPlayer.end(); break; case ERROR: { WebChromeClient client = mWebView.getWebChromeClient(); if (client != null) { client.onHideCustomView(); } break; } case LOAD_DEFAULT_POSTER: { WebChromeClient client = mWebView.getWebChromeClient(); if (client != null) { doSetPoster(client.getDefaultVideoPoster()); } break; } case TIMEUPDATE: { if (VideoPlayer.isPlaying(this)) { sendTimeupdate(); } break; } case BUFFERING_START: { VideoPlayer.setPlayerBuffering(true); break; } case BUFFERING_END: { VideoPlayer.setPlayerBuffering(false); break; } /// M: set mute/volume @{ case SET_VOLUME: { float volume = ((float) msg.arg1 / 100); VideoPlayer.setVolume(volume); break; } /// @} /// M: for shutting down player @{ case TEARDOWN: { VideoPlayer.teardown(); break; } /// @} } }
// When there is a frame ready from surface texture, we should tell WebView // to refresh. @Override public void onFrameAvailable(SurfaceTexture surfaceTexture) { // TODO: This should support partial invalidation too. mWebView.invalidate(); }