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.
Asked
Active
Viewed 4,668 times
1
-
Is there any control like webbrowser like C# winform can you use in android? maybe you can use some control to make it. I just know a little about android, hope this can help you. – Tim Li Feb 11 '11 at 10:06
-
Maybe this solution will help: http://stackoverflow.com/questions/7257389/youtube-video-not-showing-in-webview/7790908#7790908 – Ronnie Oct 17 '11 at 08:07
2 Answers
3
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");
-
2Is not working, Only showing white screen and blue box. i.e. plugins unavailable. – Ranjitsingh Chandel Oct 03 '12 at 11:43
0
Try Android Youtube Player API read more here : https://developers.google.com/youtube/android/player/

subair_a
- 1,028
- 2
- 14
- 19