Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed youtube video in Phonegap ios app

Tags:

ios

cordova

I've been searching for a long time for a solution but all i can find are things related to the old versions of phonegap.

I basically need to include some youtubes videos on my app, but currently using a include code such as:

<iframe width="240" height="180" src="http://www.youtube.com/embed/PEfxz7PuI0g" allowfullscreen></iframe>

This doesn't display anything apart from the space the video would take up, just a grey box. I'm using phonegap 2.9.0 and the latest version of xCode. I've tried setting the domains to allow youtube, but this didn't help:

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

I believe that was for previous versions of phonegap apps for ios. Can anyone help, it would be appreciated.

like image 984
Doidgey Avatar asked Oct 29 '13 15:10

Doidgey


People also ask

How do I embed a YouTube video in SwiftUI?

WebViews in SwiftUI Just replace the URL in the WebViewModel init with your YouTubeURL and that's it, you have a YouTube video embedded in the app.


2 Answers

try the below code hope it will help full for you

var video_embeded='PEfxz7PuI0g';

<object><param name="movie" value="https://www.youtube.com/v/'+video_embeded+'&hl=en_US&feature=player_embedded&version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="https://www.youtube.com/v/'+video_embeded+'?suggestedQuality=medium&hl=en_US&feature=player_embedded&version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always"></embed></object>

this is help full for me....

like image 77
Gopal vaid Avatar answered Oct 19 '22 20:10

Gopal vaid


I had a similar issue with a PhoneGap app. The video (either YouTube or Vimeo) worked well on Android, but on iOS there was just an empty space. I tried many different solutions, but the only one that really worked was adding the following lines to config.xml:

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

Hope this helps.

like image 5
Code Your Dream Avatar answered Oct 19 '22 19:10

Code Your Dream