Android – How to play Youtube video in WebView

androidwebviewyoutube

I need to play youtube video in the webview,but when I load the URL the entire youtube mobile page is loaded. I want only a player or a way to embed the video in the webview, like in IOS. Is it possible? With the iframe tag the video doesn't load, it say that an error occurred.
Thanks.

Best Answer

Use the Code to display an embedded Video in your Source for the WebView:

<iframe width="560" height="315" src="http://www.youtube.com/embed/...." frameborder="0" allowfullscreen></iframe>

You can find the URL for the src-Tag if you got to the Youtube Website and click on share -> embed.

But why do you use WebView? There you have to play the Videos in Flash. The Android VideoView can also stream Youtube Videos.