问题描述
我有以下代码:
<video controls autoplay>
<source src="video/myVideo.mp4" type="video/mp4">
<source src="video/myVideo.webm" type="video/webm">
<source src="video/myVideo.ogv" type="video/ogg"> </video>
视频:
- 在 Chrome 和 Firefox 中显示良好
- 在 Firefox 中,它按预期播放
- 在 Chrome 中,它显示但不自动启动".这就是问题所在.
- 如果我点击它(在 Chrome 中)它可以正常播放
尝试过
<video controls autoplay>...</video>
<video controls autoplay="1">...</video>
<video controls autoplay="autoplay">...</video>
Chrome 没有任何效果
Nothing worked in Chrome
然后我也尝试按照 https://en.wikipedia.org/wiki 中的建议更改编解码器/HTML5_video,但它也不起作用:
Then I also tried changing the codec, as recommended in https://en.wikipedia.org/wiki/HTML5_video, but it also did not work:
<source src="movie.webm" type='video/webm; codecs="vp8.0, vorbis"'>
<source src="movie.ogv" type='video/ogg; codecs="theora, vorbis"'>
<source src="movie.mp4" type='video/mp4; codecs="avc1.4D401E, mp4a.40.2"'>
所以现在我陷入了死胡同.感谢您的任何指点!非常感谢.
So now I am at a dead end. Thanks for any pointers! Much appreciated.
推荐答案
您需要添加 playsinline autoplay muted loop
因为 Chrome 不允许视频在未静音的情况下自动启动.另外,现在我不知道为什么它不适用于所有 Android 设备.我想看看它是否是特定于版本的,如果我找到了我会告诉你的.
You need to add playsinline autoplay muted loop
because Chrome does not allow a video to autostart if it is not muted. Also, right now I don't know why it is not working in all Android devices. I'm trying to look if it's version specific, if I find something I'll let you know.
Chrome 问题:经过一些研究,我发现它有时在 Chrome 上不起作用,因为在响应时您可以激活数据保护程序,并且它会阻止任何视频自动启动.
Chrome issue:After some research I have found that it doesn't work on Chrome sometimes because in responsive you can activate the data saver, and it blocks any video to autostart.
这篇关于HTML 5 视频“自动播放"在 CHROME 中不会自动启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!