gpt4 book ai didi

javascript - 2020 : iOS Safari Video Autoplay Options?

转载 作者:行者123 更新时间:2023-12-04 09:32:21 25 4
gpt4 key购买 nike

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

有些人提到了视频转码或使用 playsinline(适用于 Android),但对 iOS/Safari 没有任何效果。

最佳答案

我相信以下仍然是 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.

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

这还要求视频元素具有“playsinline”属性。

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

另外一个注意事项 - 如果您的用例是针对 WebView 而不是常规浏览器,那么您将拥有更多控制权。请在此处查看“wkwebviewconfiguration”的文档,尤其是“mediaTypesRequiringUserActionForPlayback”:

关于javascript - 2020 : iOS Safari Video Autoplay Options?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62780281/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com