Youtube播放器Api静音音量

时间:2014-09-16 20:10:21

标签: javascript jquery youtube-api youtube-javascript-api

我正在使用youtube的代码在我的网站上加载视频,但我无法找到如何静音音量。这可能吗?

<script>
  // Load the IFrame Player API code asynchronously.
  var tag = document.createElement('script');
  tag.src = "https://www.youtube.com/player_api";
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);


  var player;
  function onYouTubePlayerAPIReady() {
    player = new YT.Player('ytplayer', {
      height: '300',
      width: '250',
      autoplay : 1,
      videoId: '5Wu9DxtyLWE',
      events: {
      "onReady": onPlayerReady,
      "onStateChange": onPlayerStateChange
 }
});
}

function onPlayerReady(event) {
event.target.playVideo();
}

function onPlayerStateChange(event) {        
if(event.data === 0) {
}
}

</script>

感谢所有..

1 个答案:

答案 0 :(得分:1)

我找到了解决方案......显然我必须阅读更多关于此事的内容。 player.mute();