html - 如何关闭自动播放

标签 html iframe video mp4 autoplay

我在 iframe 标记中嵌入了一个 .mp4 视频。我不知道如何关闭自动播放。我尝试了一切:autoplay =“false”,autoplay =“0”,autoplay ='false',autoplay ='0'但似乎没有任何效果。这是我的代码:

<div class="embed-responsive embed-responsive-16by9">
  <iframe class="embed-responsive-item behind" src='videos/cloud_computing.mp4' width='640' height='360' style='width:640px;height:360px;'></iframe>
</div>

在此之前有一个 YouTube 视频(无法自动播放),代码如下所示:

<div class="embed-responsive embed-responsive-16by9">
  <iframe class="embed-responsive-item behind" src='https://www.youtube.com/embed/v1uyQZNg2vE?enablejsapi=1&amp;html5=1&amp;hd=1&amp;wmode=transparent&amp;controls=1&amp;showinfo=0;rel=0;' width='640' height='360' style='width:640px;height:360px;'></iframe>
</div>

最佳答案

你需要输入<video>标记围绕它,因为它不知道 iframe因此是视频 autoplay永远不会工作。尝试下面的代码。

   <div class="embed-responsive embed-responsive-16by9">
          <iframe class="embed-responsive-item behind"> 
           <video src='videos/cloud_computing.mp4'
             width='640' height='360' style='width:640px;height:360px;' autoplay="0">
            </video>
        </iframe>
        </div>

Note

我会使用autoplay="0"autoplay="1"因为 chrome 无法识别autoplay="true"autoplay="false" .

关于html - 如何关闭自动播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31434077/

相关文章:

用于视频的 Javascript 新窗口未在 IE 中调整大小

php - 使用 PHP 从图像创建定格动画视频

IOS-如何将视频添加为 ViewController 背景并使用 swift 在运行时添加约束

html - 页面上的 Bootstrap Affix 和不透明度

html - Flexbox child ,行和列的混合

c# - 从字符串 C# 构建表

video - 在同一命令中减小使用 ffmpeg 制作的视频的大小

javascript - document.getElementById ("test").style.display ="hidden"不工作

javascript - SharePoint 2013 应用程序部分 - 不使用 iFrame 或 iFrame 之外的流动元素

javascript - 动态添加 iframe 时不需要的页面重新加载