How to embed Youtube video in Cordova Android App

I am new to Cordova application development.

I have a Youtube URL and I want to embed a video in a Cordoba app. I tried to do this with YouTube Api (JS Library) and with iframe. What do I need to do to upload the video to the Android app?

+6
source share
4 answers

Using iframes is the preferred and suggested way to embed videos on YouTube, so you should continue. The startup code from the YoutTube iframe API downloads and works both on iOS (tested on iOS 7) and on Android (tested on Android 4.3).

+5
source

For me, the solution edited the config.xml file, adding the following lines:

 <preference name="AllowInlineMediaPlayback" value="true" /> <preference name="MediaPlaybackRequiresUserAction" value="false" /> <allow-navigation href="*youtube*" /> <allow-navigation href="*ytimg*" /> 
+9
source

Adding the = player_embedded parameter function to the iframe url works fine for me:

 <iframe width="640" height="360" src="http://www.youtube.com/embed/*********?feature=player_embedded" frameborder="0" allowfullscreen></iframe> 
0
source

If you are not using <access origin="*" /> (not recommended), you will need to allow the following domains with your config.xml to embed youtube video into the cordova Android developer application:

 <access origin="https://*.youtube-nocookie.com" /> <access origin="https://*.youtube.com" /> <access origin="https://*.ytimg.com" /> <access origin="https://*.gstatic.com" /> <access origin="https://*.googlevideo.com" /> <access origin="https://*.google.com" /> 

This is used for privacy-enhanced insertion mode. The youtube-nocookie domain is apparently not required for a standard attachment.

0
source

All Articles