Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android chrome webview客户端没有';我不能全屏_Android_Android Webview_Webviewclient_Webchromeclient - Fatal编程技术网

Android chrome webview客户端没有';我不能全屏

Android chrome webview客户端没有';我不能全屏,android,android-webview,webviewclient,webchromeclient,Android,Android Webview,Webviewclient,Webchromeclient,我正在尝试在我的应用程序的网络视图中以全屏模式播放Youtube视频。我能够在webview中启用全屏按钮 /** MainActivity * Fullscreen video variables */ //Stores the custom view passed back by the WebChromeClient private View mCustomView; //Stores the main content view of the activity private Vi

我正在尝试在我的应用程序的网络视图中以全屏模式播放Youtube视频。我能够在webview中启用全屏按钮

/** MainActivity 
 * Fullscreen video variables
 */
//Stores the custom view passed back by the WebChromeClient
private View mCustomView;

//Stores the main content view of the activity
private View mContentView;

//Container in which to place the custom view.
private FrameLayout mCustomViewContainer;

//Stores the CustomViewCallback interface.
private WebChromeClient.CustomViewCallback mCustomViewCallback;

/**
 * Method to mirror onShowCustomView from the WebChrome client, allowing WebViews in a Fragment
 * to show custom views.
 * @param view - The custom view.
 * @param callback - The callback interface for the custom view.
 */
public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
    //If there's already a custom view, this is a duplicate call, and we should
    // terminate the new view, then bail out.
    if (mCustomView != null) {
        callback.onCustomViewHidden();
        return;
    }

    //Create a reusable set of FrameLayout.LayoutParams
    FrameLayout.LayoutParams fullscreenParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT);

    //Save the drawer view into an instance variable, then hide it.
    mContentView = findViewById(R.id.activity_main);
    mContentView.setVisibility(View.GONE);

    //Create a new custom view container
    mCustomViewContainer = new FrameLayout(InAppLandingPageActivity.this);
    mCustomViewContainer.setLayoutParams(fullscreenParams);
    mCustomViewContainer.setBackgroundResource(android.R.color.black);

    //Set view to instance variable, then add to container.
    mCustomView = view;
    view.setLayoutParams(fullscreenParams);
    mCustomViewContainer.addView(mCustomView);
    mCustomViewContainer.setVisibility(View.VISIBLE);

    //Save the callback an instance variable.
    mCustomViewCallback = callback;
}

/**
 * Method to mirror onShowCustomView from the WebChrome client, allowing WebViews in a Fragment
 * to hide custom views.
 */
public void hideCustomView() {
    if (mCustomView == null) {
        //Nothing to hide - return.
        return;
    } else {
        // Hide the custom view.
        mCustomView.setVisibility(View.GONE);

        // Remove the custom view from its container.
        mCustomViewContainer.removeView(mCustomView);
        mCustomViewContainer.setVisibility(View.GONE);
        mCustomViewCallback.onCustomViewHidden();
        mCustomView = null;

        // Show the ActionBar
        getSupportActionBar().show();

        // Show the content view.
        mContentView.setVisibility(View.VISIBLE);
    }
}
Chrome客户端:

private  class MyWebChromeClient extends ChromeClient {


    @Override
    public void onShowCustomView(View view, CustomViewCallback callback) {
        super.onShowCustomView(view, callback);
        MainActivity activity = (MainActivity) getActivity();
        try {
            activity.showCustomView(view, callback);
        } catch (Exception ex) {
            Logger.i(TAG, "Failed onShowCustomView", ex);
        }
    }

    @Override
    public void onHideCustomView() {
        super.onHideCustomView();
        MainActivity activity = (MainActivity) getActivity();
        activity.hideCustomView();
    }
}
布局文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:pandora="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
    android:id="@+id/web_fragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

 </LinearLayout>

当我点击全屏按钮时,我得到以下错误,屏幕为灰色,视频音频仍在播放 [错误:shared_renderer_state.cc]请求总账进程失败。可能出现僵局