-1

I want to open youtube videos in a webview. In a webview I go to the page of a video in youtube and when I try to play the video, it doesnot start. Is it possible to play youtube videos in a webview? If it is not, how can I direct my application to open the video with native media player of the phone.

user1488918
  • 140
  • 1
  • 7
  • take a look at this SO post. http://stackoverflow.com/questions/2292086/play-youtube-video-in-webview – Orlymee Jul 06 '12 at 10:58

1 Answers1

0

Try with this code:

myWebView = (WebView) findViewById( R.id.webview);

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

myWebView.loadData(playVideo, "text/html", "utf-8");

And yes dont forget to add permission into your manifest:

<uses-permission  android:name="android.permission.INTERNET"/>

I hope this will help you.

AkashG
  • 7,868
  • 3
  • 28
  • 43