3

私のシナリオを説明しましょう。Youtube IFrame APIを使用して、自分のWebサイトにいくつかのビデオを埋め込みたいです。このページでIDwdGZBRAwW74https://www.youtube.com/watch?v=wdGZBRAwW74 )のビデオをテストしました: Youtube IFramePlayerDemo 。そして、それは問題なく動作します。

このサンプルコードを試してみます:

<!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はエラー150でonErrorを起動し、埋め込みプレーヤーに「この動画には、ブロックしたVEVOのコンテンツが含まれています。このウェブサイトの表示から。Youtubeで見る"
  3. ドメインapp.musiccentaur.com/youtube/index.htmの場合:最初のケースと同様に、すべてが正常に機能します
  4. ドメインapp.centaurmusic.com/youtube /の場合:最初のケースと同様に、すべてが正常に機能します

私が知っているように、エラー150は、「要求されたビデオの所有者は、埋め込みプレーヤーでの再生を許可していません」を表します。しかし、ケース1、3、4でも機能するようですが、どういう意味ですか?

この問題に関連するVevoのすべてのビデオのようです。Vevoが動画を埋め込むためのポリシーを定義したかどうかはわかりません。

問題は私のドメインmusic.comにあるのかもしれませんが、VevoのビデオをWebサイトに埋め込むためのドメインのルールがあるかどうかはわかりません。

ウェブサイトのドメインを購入した場合、エラー150が発生しますが、これは非常に悪いことです。:(

以前にこれに対処した人はいますか?解決策を教えてください。前もって感謝します。

注:このエラーはVevoのビデオでのみ発生します。

4

1 に答える 1

2

コンテンツ所有者は、埋め込みが許可/拒否されるドメイン名のホワイト/ブラックリストを設定できます。これらの制限を回避する方法はありません。

このブログ投稿には、一般的なコンテンツ制限に関するもう少し詳しい情報があります:http: //apiblog.youtube.com/2011/12/understanding-playback-restrictions.html

于 2012-11-30T16:25:05.290 に答える