本文介绍了如何播放YouTube视频的WebView在android系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在web视图中的Android播放YouTube视频,这不应该在新窗口中打开。它只应发挥的WebView在Android上。
I want to play a YouTube video in webview in android, which should not open in a new window. It should only play in webview on android.
推荐答案
您可以试试这一个,它为我工作。
You can try this one, it works for me.
WebView video = (WebView) findViewById(R.id.video);
String widthAndHeight = "width='220' height='200'";
String videoURL = "http://www.youtube.com/v/DZi6DEJsOJ0?fs=1&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.getSettings().setJavaScriptEnabled(true);
video.getSettings().setPluginsEnabled(true);
video.loadData(temp,"text/html", "utf-8");
这篇关于如何播放YouTube视频的WebView在android系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!