Youtube视频可使用默认嵌入播放,但不能使用Youtube api播放

Youtube视频可使用默认嵌入播放,但不能使用Youtube api播放,youtube,youtube-api,youtube-data-api,Youtube,Youtube Api,Youtube Data Api,我有一些YT视频要在VB Webbrowser中播放,但播放它会给我“这个视频包含来自VEVO的内容”。它被限制在某些站点或应用程序的错误上播放。但是,当我尝试使用Youtube链接中提供的默认嵌入代码播放它时,它可以完美地播放。例如: <iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allowfullscreen></iframe&

我有一些YT视频要在VB Webbrowser中播放,但播放它会给我“这个视频包含来自VEVO的内容”。它被限制在某些站点或应用程序的错误上播放。但是,当我尝试使用Youtube链接中提供的默认嵌入代码播放它时,它可以完美地播放。例如:

<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allowfullscreen></iframe>
在定制的HTML页面上,这是我使用的代码

function main(vidid)
  {
        // 2. This code loads the IFrame Player API code asynchronously.
  var tag = document.createElement('script');

  tag.src = "https://www.youtube.com/iframe_api";
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  // 3. This function creates an <iframe> (and YouTube player)
  //    after the API code downloads.
  var player;
  window.onYouTubeIframeAPIReady = function() {
    player = new YT.Player('player', {
      height: '200',
      width: '300',
      playerVars: {
                autoplay: 1,
                enablejsapi : 1,
                origin: "https://www.youtube.com",
                vq: 'medium'},
      videoId: vidid,
      events: {
        'onReady': onPlayerReady,
        'onStateChange': onPlayerStateChange
      }
    });
  }

  // 4. The API will call this function when the video player is ready.
  function onPlayerReady(event) {
    event.target.playVideo();
  }

  // 5. The API calls this function when the player's state changes.
  //    The function indicates that when playing a video (state=1),
  //    the player should play for six seconds and then stop.
  var done = false;
  function onPlayerStateChange(event) {
    if (event.data == YT.PlayerState.PLAYING && !done) {
      setTimeout(stopVideo, 6000);
      done = true;
    }
  }
  function stopVideo() {
    player.stopVideo();
  }
}

是我遗漏了什么,还是视频只是针对API用户屏蔽的?如果我的问题太糟糕,我深表歉意。

找到了问题的根源。原来我是在PC上托管这个网页的,这是Youtube不允许的。在我将我的html页面上传到web服务器后,它工作得非常好。

你想用RickAstley spamvid向我们发送垃圾邮件!!!!!!!正如你所知,我通过各种方式进行了测试,效果良好。如果你愿意,可以在这里玩对不起,哈哈。这可能是Visual Studio网络浏览器的问题吗?