Android – How To Embed YouTube Video on Android using Phonegap

androidcordovaembedvideoyoutube

I've been trying to embed YouTube videos inside my phonegap Android app using the new YouTube iframe API.
The embed itself working and a YouTube window pops in with the preview picture and the play button in the center.
The problem is when I click the button to start streaming the video the embed doesn't play the video – just loads the preview picture in and does nothing.

The code used is below if it helps.

 & lt;iframe title="YouTube video player"
class="YouTube-player" type="text/HTML" width="320" height="194"
src="http://www.youtube.com/embed/xxxxxxxx" frameborder="0"></iframe>

I read from any article that if using iPhone just change setting on phonegap.plist this

MediaPlaybackRequiresUserAction: NO
AllowInlineMediaPlayback: YES
OpenAllWhitelistURLsInWebView: YES
ExternalHosts
          *.youtube.com
          *.ytimg.com

how about in android…?

Best Answer

Please used this plugin to play youtube video in android-phonegap application.
Please follow steps given in this blog.

After successful integration of plugin used following code to play youtube video:

window.plugins.videoPlayer.play("http://www.youtube.com/watch?v=E0UV5i5jY50");