在iOS / iPhone上的Ionic / Cordova / PhoneGap应用程序中嵌入YouTube视频 [英] Inline YouTube video in Ionic/Cordova/PhoneGap app on iOS/iPhone

查看:1031
本文介绍了在iOS / iPhone上的Ionic / Cordova / PhoneGap应用程序中嵌入YouTube视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在iPhone上的Ionic / Cordova / PhoneGap应用程式中嵌入YouTube影片?我已经尝试了所有的顶部结果在这里和谷歌无济于事。无论是嵌入iframe,物件还是透过YouTube iframe API,影片总是以全萤幕开启。



有许多iOS应用程式可以达到这个目的。他们如何实现这一目标?这可以被劫持并实现到Cordova应用程序?通过Cordova插件,例如?

解决方案

我终于得到了这个工作。



首先,插入YouTube视频,如下所示:

 < iframe class =embed-responsive-itemsrc =https://www.youtube.com/embed/XL9528Gohe0?autohide=1&playsinline=1&showinfo=0frameborder =0allowfullscreen =>< / iframe> 

接下来,关闭Xcode并编辑config.xml

 <$ c 

$ c>< preference name =AllowInlineMediaPlaybackvalue =true/>

保存,重建项目,在Xcode中打开并再次运行。您的YouTube视频现在应该内联播放。在iPhone 6的最新iOS(9.1)上测试。


How can I get a YouTube video to play inline in an Ionic/Cordova/PhoneGap app on iPhone? I've tried all the top results on here and Google to no avail. Whether I embed with an iframe, an object, or via the YouTube iframe api, the video always opens in full screen.

There are lots of iOS apps which achieve this. How are they achieving this? And can this somehow be hijacked and implemented into a Cordova app? Via a Cordova plugin, for example?

解决方案

I finally got this working.

First, insert the YouTube video like so:

<iframe class="embed-responsive-item"  src="https://www.youtube.com/embed/XL9528Gohe0?autohide=1&playsinline=1&showinfo=0" frameborder="0" allowfullscreen=""></iframe>

Next, close down Xcode and edit config.xml (usually in the root of your project).

Add this line under the other preferences:

<preference name="AllowInlineMediaPlayback" value="true" />

Save it, rebuild the project, open in Xcode and run again. Your YouTube video should now be playing inline. Tested on latest iOS (9.1) on iPhone 6.

这篇关于在iOS / iPhone上的Ionic / Cordova / PhoneGap应用程序中嵌入YouTube视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆