【问题标题】:Why is this embedded iframe video not playing?为什么这个嵌入的 iframe 视频没有播放?
【发布时间】:2015-11-07 07:40:13
【问题描述】:

我想在我的网站上添加这个视频。我添加了这段代码,但它不起作用。请帮帮我。

<div id="container">
  <iframe id="vid" width="560" height="315" src="https://www.youtube.com/watch?v=NhxVR2Szu3k&noredirect=1" frameborder="0" allowfullscreen></iframe>
</div>
<style>
#container {
    border: 1px solid red;
    width: 560px;
    text-align: center;
}
#vid {
    margin-bottom: 25px;   
}
</style>

【问题讨论】:

  • 视频不显示
  • 请检查代码

标签: javascript html iframe video youtube


【解决方案1】:

更新 请用您的代码替换它

<div id="container">
  <iframe width="560" height="315" src="https://www.youtube.com/embed/NhxVR2Szu3k" frameborder="0" allowfullscreen></iframe>
</div>

和css

#container {
    border: 1px solid red;
    text-align:center;
    width: 80%;
    margin-left:auto;
    margin-right:auto;
}

因为您没有使用正确的视频代码..进入视频链接..然后分享然后嵌入代码并获取该代码,它会起作用..希望这有助于。

更新:现在您的视频是响应式的..根据您的需要更改宽度。

【讨论】:

  • 我需要更多帮助,这个视频正在播放,但是当视频完成后,它会继续播放下一个视频,但我不想要下一个视频
  • 这是 youtube 的大问题..您可以清除单个 cookie,然后再次运行 youtube,但我不确定它是否会帮助很多用户面临这个问题..在这里阅读更多 productforums.google.com/forum/#!topic/youtube/ZSdaqRSmG2k跨度>
  • 是的...请检查我更新的代码..根据您的需要更改宽度。
【解决方案2】:

我没有清楚地理解您想要实现的目标,但请尝试以下示例:

<html>
<head> </head>
<body>  
            <div style="text-align:center"> 
              <button onclick="playPause()">Play/Pause </button> 
              <br> 
              <video id="video" width="420">
                <source src="video.mp4" type="video/mp4">
                Your browser does not support HTML5 video.
              </video>
            </div> 
            
            <script> 
            var myVideo = document.getElementById("video "); 
            
            function playPause() { 
                if (myVideo.paused) 
                    myVideo.play(); 
                else 
                    myVideo.pause(); 
            } 
            </script>               
</body>
</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-13
    • 2021-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-12
    • 2011-12-26
    相关资源
    最近更新 更多