2020: iOS Safari Video Autoplay Options?

匆匆过客 提交于 2020-07-19 11:30:33

问题


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?

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


回答1:


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

elements will now honor the autoplay attribute, for elements which meet the following conditions:

  • elements will be allowed to autoplay without a user gesture if their source media contains no audio tracks.
  • elements will also be allowed to autoplay without a user gesture.
  • If a element gains an audio track or becomes un-muted without a user gesture, playback will pause.
  • elements will only begin playing when visible on-screen such as when they are scrolled into the viewport, made visible through CSS, and inserted into the DOM.
  • elements will pause if they become non-visible, such as by being scrolled out of the viewport.

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

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.

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:

  • https://developer.apple.com/documentation/webkit/wkwebviewconfiguration


来源:https://stackoverflow.com/questions/62780281/2020-ios-safari-video-autoplay-options

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