1

我已经尝试了很多,但是如果我单击视频,则 YouTube 视频没有加载到 webview 中,共享和点赞操作栏将显示

下面是我的源代码

     mWebView.setWebViewClient(new MyWebViewClient());
        mWebView.loadUrl(sabNZBurl);
        mWebView.getSettings().setDomStorageEnabled(true);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.getSettings().setBuiltInZoomControls(true);
        mWebView.getSettings().setSupportZoom(true);

}

     class MyWebViewClient extends WebViewClient {
    @Override
    // Show in WebView instead of Browser
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        WebView engine = new WebView(YoutubeActivity.this);
        engine.getSettings().setJavaScriptEnabled(true);
        engine.getSettings().setPluginsEnabled(true);
        Log.i("YoutubeActivity", "MyWebViewClient: shouldOverrideUrlLoading");

        String temp = "<object " + "width='220' height='200'" + ">" + "<param name='allowFullScreen' value='false'>" + "</param><param name='allowscriptaccess' value='always'>" + "</param><embed src='"
                + url + "'" + " type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true'" + "width='220' height='200'" + "></embed></object>";

        engine.getSettings().setJavaScriptEnabled(true);
        engine.getSettings().setPluginsEnabled(true);
        engine.loadData(temp, "text/html", "utf-8");
        return true;
    }

AndroidManifyt.xml

       <activity
        android:name=".Youtube.YoutubeActivity"
        android:screenOrientation="portrait" 
        android:hardwareAccelerated="true">

屏幕截图如下

在此处输入图像描述

在此处输入图像描述

当我点击 youtube 视频时,操作栏将带有喜欢和分享按钮,但视频不加载

4

0 回答 0