Error creating a FrameLayout to play videos in WebView full screen

0

I created a webview to view a website with YouTube videos linked to it. However, these can not be viewed in full screen. In this previous question , where I asked about how to make such a solution, they responded with a Framelayout.

The problem is that the code does not compile, the sector of mCustomViewCallback does not work. It is indicated in red in Visual Studio.

package cl.yellowdesign.mathemapp;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.view.View;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.webkit.WebChromeClient;
import android.webkit.WebView;


public class webview_load extends AppCompatActivity {
    private WebView WV;
    private View mCustomView;

    private FrameLayout frameLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_webview_load);
        WV = (WebView) findViewById(R.id.wv);
        WebSettings webSettings = WV.getSettings();
        webSettings.setJavaScriptEnabled(true);
        WV.loadUrl("http://www.campusmathema.com/nuevo/");
        WV.setWebViewClient(new WebViewClient());
        frameLayout = findViewById(R.id.container);
        WV.setWebChromeClient(new WebChromeClient(){


            @Override
            public void onShowCustomView(View view, CustomViewCallback callback) {
                super.onShowCustomView(view, callback);
                if (mCustomView != null) {
                    callback.onCustomViewHidden();
                    return;
                }
                mCustomView = view;
                WV.setVisibility(View.GONE);
                frameLayout.setVisibility(View.VISIBLE);

                frameLayout.addView(view);
                mCustomViewCallback = callback;
            }

            @Override
            public void onHideCustomView() {
                super.onHideCustomView();
                if (mCustomView == null)
                    return;

                WV.setVisibility(View.VISIBLE);
                frameLayout.setVisibility(View.GONE);
                mCustomView.setVisibility(View.GONE);
                frameLayout.removeView(mCustomView);
                mCustomViewCallback.onCustomViewHidden();

                mCustomView = null;

            }

        });
    }

    @Override
    public void onBackPressed() {
        if(WV.canGoBack())
        {
           WV.goBack();
        } else {
            super.onBackPressed();
        }
    }
}
    
asked by Mr.greystark 23.02.2018 в 01:59
source

0 answers