如何禁用html5视频自动播放?
我尝试过的:
<video width="640" height="480" controls="controls" type="video/mp4" autoplay="false" preload="none"><source src="http://mydomain.com/mytestfile.mp4">Your browser does not support the video tag.</video>
我将删除autoplay属性,因为如果浏览器找到自动播放字符串,它会自动播放!
自动播放不是布尔类型.
此外,类型进入源代码,如下所示:
<video width="640" height="480" controls preload="none"> <source src="http://example.com/mytestfile.mp4" type="video/mp4"> Your browser does not support the video tag. </video>
参考:http://www.w3.org/TR/html-markup/video.html
删除视频标记中的自动播放.使用这样的代码
<video class="embed-responsive-item" controls> <source src="http://example.com/video.mp4"> Your browser does not support the video tag. </video>
这是100%的工作
尝试添加autostart="false"到源标记.
<video width="640" height="480" controls="controls" type="video/mp4" preload="none"> <source src="http://example.com/mytestfile.mp4" autostart="false"> Your browser does not support the video tag. </video>