javascript Javascript YouTube视频播放器(多个)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Javascript YouTube视频播放器(多个)相关的知识,希望对你有一定的参考价值。

// 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);

// Replace the 'ytplayer' element with an <iframe> and
// the YouTube player, after the API code downloads
var player;
var player2;
function onYouTubeIframeAPIReady() {
  player1 = new YT.Player('ytplayer1', {
    height: '270',
    width: '480',
    playerVars: {
          autoplay: 1,
          loop: 1,
          controls: 0,
          allowfullscreen: 0,
          rel: 0,
          showinfo: 0
      },
    events: {
      onStateChange:
      function(e) {
          if (e.data === YT.PlayerState.ENDED) {
              player1.mute();
              player1.playVideo();
          }
      }
    },
    videoId: 'VRbYVLTouUA'
  });
  player2 = new YT.Player('ytplayer2', {
    height: '270',
    width: '480',
    playerVars: {
          autoplay: 1,
          loop: 1,
          controls: 0,
          allowfullscreen: 0,
          rel: 0,
          showinfo: 0
      },
    events: {
      onStateChange:
      function(e) {
          if (e.data === YT.PlayerState.ENDED) {
              player2.mute();
              player2.playVideo();
          }
      }
    },
    videoId: 'ivX8aM9Q0SE'
  });
}
function onPlayerReady(event) {
    player1.mute();
    player2.mute();
    player1.playVideo();
    player2.playVideo();
}

以上是关于javascript Javascript YouTube视频播放器(多个)的主要内容,如果未能解决你的问题,请参考以下文章

javascript 来自https://forums.developer.amazon.com/questions/75835/can-you-please-provide-a-video-skil

36个助你成为专家需要掌握的JavaScript概念

javascript 用计算机暴力解一元方程

You have ettempted to queue to many files.You may select one files.

Javascript电子邮件验证

网站前端_JavaScript.0013.JavaScript包装类型