1

I have m.youtube.com (my channel) in webview, but then I select the video and click play it don´t play video, only show toolbar.

My code:

    webView = (WebView) view.findViewById(R.id.webview1);
    webView. getSettings().setJavaScriptEnabled (true);
    webView. getSettings().setJavaScriptCanOpenWindowsAutomatically (false);
    webView. getSettings().setPluginsEnabled (true);
    webView. getSettings().setSupportMultipleWindows (false);
    webView. getSettings().setSupportZoom (false);
    webView. setVerticalScrollBarEnabled (false);
    webView. setHorizontalScrollBarEnabled (false);
    webView.loadUrl("http://m.youtube.com/studiodamageofficial/?uid=sJX2-Ux9B6zShh5B4dHhQ&desktop_uri=%2Fstudiodamageofficial%2F");

    webView. setWebViewClient (new WebViewClient () {
        @ Override public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (url.startsWith("vnd.youtube")){

        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));

        return true;
        }
        else
        {
        return false;
        }
        }
    });  

So what is the problem?

EDIT:

I can go to the channel,but when i click on the video, it say Loading and then say An error occured while performing this operation.

Actually code:

    webView = (WebView) view.findViewById(R.id.webview1);
    webView. getSettings().setJavaScriptEnabled (true);
    webView. getSettings().setJavaScriptCanOpenWindowsAutomatically (false);
    webView. getSettings().setPluginsEnabled (true);
    webView. getSettings().setSupportMultipleWindows (false);
    webView. getSettings().setSupportZoom (false);
    webView. setVerticalScrollBarEnabled (false);
    webView. setHorizontalScrollBarEnabled (false);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setUseWideViewPort(true);
    webView.getSettings().setBuiltInZoomControls(true);

    webView. setWebViewClient (new WebViewClient (){

        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            //edURL.setText(url);
            return true;
        }
    });  

    try {
        webView.loadUrl("http://m.youtube.com/studiodamageofficial/?uid=sJX2-Ux9B6zShh5B4dHhQ&desktop_uri=%2Fstudiodamageofficial%2F");
        //edURL.setText(Homepage);
    } catch (Exception e)
    {
        e.printStackTrace();
    }

edURL is in comment, because it isn't defined and say error.

4

0 回答 0