How To Embed Youtube Video In Cordova Android App
Solution 1:
For me, the solution was editing config.xml
file adding the following lines:
<preferencename="AllowInlineMediaPlayback"value="true" /><preferencename="MediaPlaybackRequiresUserAction"value="false" /><allow-navigationhref="*youtube*" /><allow-navigationhref="*ytimg*" /><allow-navigationhref="*youtube-nocookie*" />
Solution 2:
Using iframe is the preferred and suggested way to embed youtube videos, so this is how you need to proceed. The getting started code from the YoutTube iframe API reference loads and works in both iOS (tested on iOS 7) and Android (tested on Android 4.3).
Solution 3:
Adding the parameter feature=player_embedded to the iframe url worked fine for me:
<iframewidth="640"height="360"src="http://www.youtube.com/embed/*********?feature=player_embedded"frameborder="0"allowfullscreen></iframe>
Solution 4:
Unless you are using <access origin="*" />
(not recommended) you will need to allow the following domains with your config.xml to embed youtube videos in an cordova android app:
<accessorigin="https://*.youtube-nocookie.com" /><accessorigin="https://*.youtube.com" /><accessorigin="https://*.ytimg.com" /><accessorigin="https://*.gstatic.com" /><accessorigin="https://*.googlevideo.com" /><accessorigin="https://*.google.com" />
This is for use with the privacy-enhanced
embed mode. The youtube-nocookie
domain presumably is not needed for a standard embed.
If you use a content security meta tag you will also need to allow those domains in your csp.
Post a Comment for "How To Embed Youtube Video In Cordova Android App"