2012-11-30 141 views
1

讓我解釋一下我的場景。我想用Youtube IFrame API在我的網站上嵌入一些視頻。 我測試了本頁面上的視頻ID wdGZBRAwW74https://www.youtube.com/watch?v=wdGZBRAwW74):Youtube IFrame Player Demo。它工作正常。Youtube IFrame API onError錯誤代碼爲150,視頻來自Vevo

我嘗試這個例子代碼:在我的本地

<!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的/索引。 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. 與域應用.centaurmusic.com/youtube /:像第一種情況,一切正常

正如我所知錯誤150代表「請求的視頻的所有者不允許它在嵌入式播放器中播放」。但是我發現它在1,3,4情況下仍然有效,那麼它是什麼意思?

看到Vevo所有關於這個問題的視頻。我不確定Vevo是否定義了一些嵌入其視頻的政策。

也許問題來自我的域名music.com,但我不確定是否有一些規則的域名嵌入在網站上的Vevo的視頻。

如果我爲我的網站購買域名,那麼我得到錯誤150,這是如此糟糕。 :(

是否有任何人處理這之前,請給我一些解決方案,在此先感謝

注:。該錯誤只發生在VEVO的視頻

+0

我不不要以爲你會能夠對Vevo的嵌入策略進行逆向工程。即使你這樣做,也不保證你的新域名也不會在晚些時候被列入黑名單。 –

回答

2

內容擁有者纔可以建立一個。上嵌入被允許/拒絕域名的黑/白名單有沒有辦法解決這些限制

本博客文章有關於內容的限制,一般多一點信息:http://apiblog.youtube.com/2011/12/understanding-playback-restrictions.html

+0

謝謝傑夫!非常有用的信息,現在我確切知道我要處理這個問題,過濾那些受限制的視頻或找到其他解決方案 –