You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 18, 2020. It is now read-only.
Provides support for full-screen video on Android
*/
public class VideoEnabledWebChromeClient extends WebChromeClient {
private final FrameLayout.LayoutParams FULLSCREEN_LAYOUT_PARAMS = new FrameLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.CENTER);
@OverRide
public void onShowCustomView(View view, CustomViewCallback callback) {
if (mVideoView != null) {
callback.onCustomViewHidden();
return;
}
// Store the view and it's callback for later, so we can dispose of them correctly
mVideoView = view;
mCustomViewCallback = callback;
view.setBackgroundColor(Color.BLACK);
getRootView().addView(view, FULLSCREEN_LAYOUT_PARAMS);
mWebView.setVisibility(View.GONE);
if(mActivity!=null){
mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
WindowManager.LayoutParams params = mActivity.getWindow().getAttributes();
params.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
mActivity. getWindow().setAttributes(params);
mActivity. getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
}
@OverRide
public void onHideCustomView() {
if (mVideoView == null) {
return;
}
mVideoView.setVisibility(View.GONE);
// Remove the custom view from its container.
getRootView().removeView(mVideoView);
mVideoView = null;
mCustomViewCallback.onCustomViewHidden();
mWebView.setVisibility(View.VISIBLE);
if(mActivity!=null){
mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
final WindowManager.LayoutParams attrs =mActivity.getWindow().getAttributes();
attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
mActivity.getWindow().setAttributes(attrs);
mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
package com.akulyk.react.androidwebview;
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.FrameLayout;
import static android.view.ViewGroup.LayoutParams;
/**
Provides support for full-screen video on Android
*/
public class VideoEnabledWebChromeClient extends WebChromeClient {
private final FrameLayout.LayoutParams FULLSCREEN_LAYOUT_PARAMS = new FrameLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.CENTER);
private WebChromeClient.CustomViewCallback mCustomViewCallback;
private Activity mActivity;
private View mWebView;
private View mVideoView;
public VideoEnabledWebChromeClient(Activity activity, WebView webView) {
mWebView = webView;
mActivity = activity;
}
@OverRide
public void onShowCustomView(View view, CustomViewCallback callback) {
if (mVideoView != null) {
callback.onCustomViewHidden();
return;
}
}
@OverRide
public void onHideCustomView() {
if (mVideoView == null) {
return;
}
}
private ViewGroup getRootView() {
return ((ViewGroup) mActivity.findViewById(android.R.id.content));
}
}
The text was updated successfully, but these errors were encountered: