Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding the YouTube iframe to a Cordova app on iOS

I'm using Cordova 3.0 and am trying to embed a YouTube video inside an article of my news app. The YouTube code looks like this:

<iframe width="600" height="450" src="//www.youtube.com/embed/_OBlgSz8sSM" frameborder="0" allowfullscreen></iframe>

In its current form the code does nothing except leave a large wide white square in the DOM. When I inject the letters http: so that it looks like this:

<iframe width="600" height="450" src="http://www.youtube.com/embed/_OBlgSz8sSM" frameborder="0" allowfullscreen></iframe>

then the app automatically quits and goes to the browser. How can I just make the iframe behave as it should, as a little window. I have followed the steps mentioned in this question and have tried fiddling with the <preference name="stay-in-webview" value="false" /> line in the config.xml file.

like image 738
Patrick Beardmore Avatar asked Feb 15 '14 16:02

Patrick Beardmore


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.


1 Answers

Is this what you are looking for Force HTML5 youtube video

<iframe src="http://www.youtube.com/embed/_OBlgSz8sSM?html5=1"></iframe>

OR may be

Show Youtube video source into HTML5 video tag?

Step 1: add &html5=True to your favorite youtube url

Step 2: Find tag in source

Step 3: Add controls="controls" to video tag:

<video controls="controls" 
       class="video-stream" 
       x-webkit-airplay="allow" 
       data-youtube-id="N9oxmRT2YWw" 
       src="http://v20.lscache8.c.youtube.com/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Cratebypass%2Coc%3AU0hPRVRMVV9FSkNOOV9MRllD&amp;itag=43&amp;ipbits=0&amp;signature=D2BCBE2F115E68C5FF97673F1D797F3C3E3BFB99.59252109C7D2B995A8D51A461FF9A6264879948E&amp;sver=3&amp;ratebypass=yes&amp;expire=1300417200&amp;key=yt1&amp;ip=0.0.0.0&amp;id=37da319914f6616c"></video>

More SF posts: YouTube video in HTML5 Force HTML5 youtube video

like image 97
N0mi Avatar answered Sep 25 '22 23:09

N0mi