HTML视频标签在iOS移动设备中无法自动播放



我有一个像这样的视频标签:

<video autoplay loop muted playsinline poster="/assets/images/video_poster_2.webp">
<source src="/assets/videos/test-vid.mp4">
<source src="/assets/videos/test-vid.webm">
</video>

目标是让它在用户进入页面时自动播放。它可以在任何地方使用,但不能在iphone上自动播放。

我添加了自动播放,静音和播放线属性,但仍然。我错过什么了吗?

提前感谢。

这是一个在IOS中自动播放视频的简单解决方案,我已经尝试过了,它在IOS, Android以及各种平台上的所有浏览器上都能完美地工作。

您可以在以下代码片段中看到工作示例:

<video class="m-video__video js-video-video" poster="/img/showreel.jpg" autoplay loop muted playsinline>
<source src="video.mp4" type="video/mp4">
poster - an image that will be shown whilst the video is loading
autoplay - this will cause the video to autoplay as soon as it’s loaded
loop - makes the video start again when it’s finished
muted - prevents any audio from playing (a video must be muted or have no audio for it to autoplay on iOS)
playsinline - this tells iOS devices to play videos inline (so the user doesn’t have to interact with it to make it play)