【问题标题】:Youtube IFrame API onError fires with error code 150 for videos from VevoYoutube IFrame API onError 触发 Vevo 视频的错误代码 150
【发布时间】:2012-11-18 09:51:09
【问题描述】:

让我解释一下我的情况。我想使用Youtube IFrame API 在我的网站上嵌入一些视频。 我在此页面上测试了 ID 为 wdGZBRAwW74 (https://www.youtube.com/watch?v=wdGZBRAwW74) 的视频:Youtube IFrame Player Demo。它工作正常。

我试试这个示例代码:

<!DOCTYPE html>
<html>
<body>
<!-- 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');
  tag.src = "//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;
  function onYouTubeIframeAPIReady() {
    player = new YT.Player('player', {
      height: '390',
      width: '640',
      videoId: 'wdGZBRAwW74',
      events: {
        'onReady': onPlayerReady,
        'onStateChange': onPlayerStateChange,
        'onError': onPlayerError
      }
    });
  }

  // 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 onPlayerError(event){
     console.log(event.data);
  }

  function stopVideo() {
    player.stopVideo();
  }
</script>
</body>
</html>

在我的本地主机上有一些虚拟主机域,我得到了结果:

  1. 使用域 app.centaur.com/youtube/index.htm:IFrame API 工作正常,视频播放没有问题。
  2. 使用域 app.music.com/youtube/index.html:IFrame API 工作正常,但视频无法播放,API 触发 onError 错误 150 并且嵌入式播放器显示消息“此视频包含来自 VEVO 的内容,该视频已阻止其在本网站上显示。在 Youtube 上观看"
  3. 使用域 app.musiccentaur.com/youtube/index.htm:与第一种情况一样,一切正常
  4. 使用域 app.centaurmusic.com/youtube/:与第一种情况一样,一切正常

据我所知,错误 150 代表“所请求视频的所有者不允许它在嵌入式播放器中播放”。但我看到它在案例 1、3、4 中仍然有效,那是什么意思?

查看 Vevo 与此问题相关的所有视频。我不确定 Vevo 是否定义了一些嵌入视频的策略。

也许问题来自我的域 music.com,但我不确定是否有一些域规则可以在网站上嵌入 Vevo 的视频。

如果我为我的网站购买了一个域,然后我收到错误 150,这太糟糕了。 :(

以前有人处理过这个吗?请给我一些解决方案。提前致谢。

注意:此错误仅发生在 Vevo 的视频中。

【问题讨论】:

  • 我认为您无法对 Vevo 的嵌入策略进行逆向工程。即使您这样做了,也不能保证您的新域以后也不会被列入黑名单。

标签: youtube-api


【解决方案1】:

允许内容所有者设置允许/拒绝嵌入的域名白/黑名单。没有办法绕过这些限制。

这篇博文有更多关于一般内容限制的信息:http://apiblog.youtube.com/2011/12/understanding-playback-restrictions.html

【讨论】:

  • 谢谢杰夫!非常有用的信息,现在我确切地知道我必须处理这个问题,过滤那些受限视频或找到其他解决方案
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-11-05
  • 2020-10-21
  • 2021-09-15
  • 2013-05-09
  • 1970-01-01
  • 1970-01-01
  • 2019-01-31
相关资源
最近更新 更多