小编use*_*132的帖子

我如何对 youtube 嵌入播放器进行编程以在单击时取消静音

如何将 youtube 嵌入式播放器设置为在单击时取消静音。您可以在http://www.harvestarmy.org主页上看到我所指的嵌入式播放器。它是右侧的那个,上面写着“来自 YouTube 的最新视频。我将其设置为默认静音,但我希望它在有人点击时自动取消静音。

这是我使用的代码:

<!-- 1. The <iframe> (and video player) will replace this <div> tag. -->
<div id="player"></div>

<script>
  // 2. This code loads the IFrame Player API code asynchronously.
  var tag = document.createElement('script');

  // This is a protocol-relative URL as described here:
  //     http://paulirish.com/2010/the-protocol-relative-url/
  // If you're testing a local page accessed via a file:/// URL, please set tag.src to
  //     "https://www.youtube.com/iframe_api" instead.
  tag.src = "//www.youtube.com/iframe_api";
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  // 3. …
Run Code Online (Sandbox Code Playgroud)

javascript embed youtube video mute

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

embed ×1

javascript ×1

mute ×1

video ×1

youtube ×1