Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed Youtube video in Cordova Android app

I am new to Cordova App development.

I have a Youtube URL and I want to embed the video in Cordova app. I have tried making it with YouTube Api(JS Library) and with iframe also. What do I have to do to make the video load on the Android app?

like image 942
Subrat Avatar asked Dec 10 '13 07:12

Subrat


People also ask

Does Cordova support iframe?

Iframes and the Callback Id MechanismIf content is served in an iframe from a whitelisted domain, that domain will have access to the native Cordova bridge.


2 Answers

Adding the parameter feature=player_embedded to the iframe url worked fine for me:

<iframe width="640" height="360" src="http://www.youtube.com/embed/*********?feature=player_embedded" frameborder="0" allowfullscreen></iframe>
like image 55
gots Avatar answered Nov 15 '22 14:11

gots


For me, the solution was editing 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*" />
<allow-navigation href="*youtube-nocookie*" />
like image 24
ErvalhouS Avatar answered Nov 15 '22 15:11

ErvalhouS