我正在使用Bootstrap 4。页面加载时,我的嵌入视频会自动播放。我的代码是:
<div class="embed-responsive embed-responsive-16by9 hoverable video-1 video-align">
<iframe class="embed-responsive-item" src="myvideo.mp4" allowfullscreen></iframe>
</div>
请问我该如何停止自动播放?
不要使用iframe;使用视频标签。内联框架用于在页面上显示另一个文档,并在加载页面时自动呈现。如果是视频,则会自动播放。
您可以这样使用autoplay="false"
:
<video width="640" height="480" controls="controls" type="video/mp4" preload="none">
<source src="myvideo.mp4" autoplay="false">
Your browser does not support the video tag.
</video>
应该是这样。
将此附加参数用于iframe:
autoplay="false"