本文介绍了2020年:iOS Safari视频自动播放选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我在这方面的所有研究和努力都遇到了障碍:目前有什么方法可以在iOS的Safari上自动播放视频?

All of my research and effort has been hitting a wall so far in this regard: Is there any way to make video autoplay on Safari in iOS currently?

有人提到视频转码或使用playsinline(在Android上有效),但在iOS/Safari上无效.

Some have mentioned video transcoding or using playsinline (which works on Android), but nothing has worked for iOS / Safari.

推荐答案

我相信以下仍然是iOS的当前图片:

I believe the following is still the current picture for iOS:

    如果
  • 元素的源媒体中没有音轨,则无需用户手势即可自动播放.
  • 元素也将被允许在没有用户手势的情况下自动播放.
  • 如果某个元素获得音轨或在没有用户手势的情况下变为静音,则播放将暂停.
  • 元素仅在屏幕上可见时才开始播放,例如,当它们滚动到视口中,通过CSS可见并插入DOM时.
  • 元素在变得不可见时会暂停,例如通过滚动到视口之外.

来源: https://webkit.org/blog/6784/new-video-policies-for-ios/

这还要求video元素具有"playsinline"属性.

This also requires that the video element has the 'playsinline' attribute.

因此,支持自动播放视频,但功能有限,因此可能无法满足您的特定需求.

So there is support for autoplay video, but it is limited so may not meet your particular needs.

另一个注意事项-如果您的用例用于Web视图而不是常规浏览器,则您拥有更多控制权.在此处查看"wkwebviewconfiguration"文档,尤其是"mediaTypesRequiringUserActionForPlayback"文档:

One other note - if your use case is for a web view rather than a regular browser, then you have more control. See the documentation for 'wkwebviewconfiguration' and in particular 'mediaTypesRequiringUserActionForPlayback' here:

这篇关于2020年:iOS Safari视频自动播放选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 08:27