3

I am new to android. Can anyone please tell how to play youtube video. My requirement is the video should display in the 'WebView' initially and on tapping that, the video should get played.

webView = (WebView)findViewById(R.id.webView1); 
WebSettings websets = webView.getSettings(); 
websets.setJavaScriptEnabled(true); 
registerForContextMenu(webView); 
webView.loadUrl("file:///android_asset/youtubes.html");
FoamyGuy
  • 46,603
  • 18
  • 125
  • 156
Keerthiraj
  • 31
  • 1
  • 2
  • The most common way to do this would be to launch your own intent and use the YouTube application to display the video.You should check out the answers to [this question][1]. [1]: http://stackoverflow.com/questions/2292086/play-youtube-video-in-webview – Mat Nadrofsky Aug 31 '11 at 13:15
  • For those finding this question, I've outlined how to make your webview able to play youtube videos here: http://stackoverflow.com/a/12850816/223440 – Nick Campion Oct 12 '12 at 03:18

1 Answers1

2

Maybe this helps, I came accross this post: link

And indeed, I basically only needed to add to the application manifest xml:

android:hardwareAccelerated="true"

And voila, even the youtube video's started playing

Only available from Android 3.0 (API level 11)

Community
  • 1
  • 1
Ronnie
  • 852
  • 12
  • 25