Android - Youtube频道在webview中播放视频

时间:2013-11-10 12:42:49

标签: android video webview youtube playing

我在webview中有m.youtube.com(我的频道),但之后我选择了视频并点击播放它不播放视频,只显示工具栏。

我的代码:

    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;
        }
        }
    });  

那么问题是什么?

编辑:

我可以转到频道,但是当我点击视频时,它会说“正在加载”,然后说执行此操作时出错。

实际上是代码:

    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正在评论中,因为它没有定义并说错误。

0 个答案:

没有答案