webkit-playsinline在返回cordova iOS应用中的页面时停止工作 [英] webkit-playsinline stops working when returning to page in cordova iOS app
问题描述
我在iOS的cordova(phonegap)应用的主页中嵌入了内嵌视频。我已将必要的允许设置添加到config.xml
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" />
并且视频html看起来像这样
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>
当应用程序首次启动视频时,内联播放工作完美无缺。但是,如果我离开主页然后返回,则视频会在页面加载时全屏显示。
我尝试在页面中移动视频以测试是否因为浏览器专注于页面加载。我也试过删除自动播放和延迟触发JS的游戏。我已经在iOS7和iOS8中测试了上述所有内容,因为这些是我的目标版本。
有什么建议吗?
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?
提前谢谢。
推荐答案
您需要在第一个window.open调用中添加'allowinlinemediaplayback = YES'。所以它看起来像这样:
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默认将allowinlinemediaplayback设置为NO,原因有些愚蠢。
InAppBrowser defaults your allowinlinemediaplayback setting to NO, for some silly reason.
这篇关于webkit-playsinline在返回cordova iOS应用中的页面时停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!