webkit-playsinline stops working when returning to page in cordova iOS app

时光怂恿深爱的人放手 提交于 2019-12-21 05:48:13

问题


I have an inline video embedded in the home page of a cordova (phonegap) app for iOS. I have added the necessary allow setting to the config.xml

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

and the the video html looks like this

<video webkit-playsinline poster="img/videoplaceholder.png" loop class="video" autoplay="autoplay">
    <source src="media/homepage.iphone.mp4"/>
</video>

When the app first launches the video plays inline and works perfectly. But if I navigate away from the homepage and then return, the video opens full screen on page load. I have tried moving the video lower in the page to test if it was because the browser was focusing on page load. I have also tried removing autoplay and delay triggering play with JS. I have tested all of the above in iOS7 and iOS8 only as those are my targeted versions. Any suggestion?

Thank you in advance.


回答1:


You need to add 'allowinlinemediaplayback=YES' to your first window.open call. So that it looks something like this:

window.open('http://google.com', 'Google', 'location=0,status=0,allowinlinemediaplayback=YES');

InAppBrowser defaults your allowinlinemediaplayback setting to NO, for some silly reason.



来源:https://stackoverflow.com/questions/26536318/webkit-playsinline-stops-working-when-returning-to-page-in-cordova-ios-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!