0

谁能帮我在 android WebView 中嵌入 YouTube 视频?

我已经尝试如下,但没有任何结果。

    browser = (WebView)findViewById(R.id.webshow);


    String html_head = "<html><body>";
    String load =html_head+" <iframe class=\"youtube-player\" type=\"text/html\" " +
                "width=\"640\" height=\"385\" src=\"http://www.youtube.com/embed/bIPcobKMB94\" frameborder=\"0\"></body></html>";

    browser.loadData(load, "text/html", "UTF-8");
4

2 回答 2

5

尝试这样做

mWebView.getSettings().setPluginState(PluginState.ON);
mWebView.getSettings().setJavaScriptEnabled(true);
于 2011-07-16T14:51:51.133 回答
0

这对我有用,所以你也可以试试

           video = (WebView) v.findViewById(R.id.videoview);
    String widthAndHeight = "width='300' height='305'";
    String videoURL = "http://www.youtube.com/v/DZi6DEJsOJ0?fs=1&amp;hl=nl_NL";

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

    video.setHorizontalScrollBarEnabled(false);
    video.setVerticalScrollBarEnabled(false);
        video.getSettings().setJavaScriptEnabled(true);
        video.getSettings().setPluginsEnabled(true);
        video.loadData(temp,"text/html", "utf-8");
于 2012-07-23T15:27:34.050 回答