How to Play Youtube video in webview in android?
I want to play a YouTube video in webview in andr开发者_高级运维oid, 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");
Try Android Youtube Player API read more here : https://developers.google.com/youtube/android/player/
精彩评论