Inline YouTube video in Ionic/Cordova/PhoneGap app on iOS/iPhone

后端 未结 3 1933
温柔的废话
温柔的废话 2021-01-21 12:09

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

相关标签:
3条回答
  • 2021-01-21 12:14

    As @Zhou Hao added in a comment, you also need

    <allow-navigation href="*://*.youtube.com/*" />
    

    Without it, it was working fine in Android, but nothing was displayed in iOS (the content of the iframe was <html><body></body></html>).

    After adding it, it worked fine on iOS also.

    This is with Cordova iOS 4.2.0.

    0 讨论(0)
  • 2021-01-21 12:24

    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.

    0 讨论(0)
  • 2021-01-21 12:31

    Use should useplaysinline as player parameter according to the documentation. youtube API

    0 讨论(0)
提交回复
热议问题