讓我解釋一下我的場景。我想用Youtube IFrame API在我的網站上嵌入一些視頻。 我測試了本頁面上的視頻ID wdGZBRAwW74(https://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>
一些虛擬主機域名和我得到的結果:
- 與域app.centaur.com/YouTube的/索引。 htm:iframe API工作正常,視頻播放沒有問題。
- 與域app.music.com /youtube/index.html:IFrame的API工作正常,但視頻不能播放,API火災的onError,錯誤150和嵌入式播放器顯示消息「這部影片含有內容。VEVO,誰已禁止在此網站中顯示在Youtube「看
- 與域app.musiccentaur.com /youtube/index.htm:像第一種情況下,一切工作正常
- 與域應用.centaurmusic.com/youtube /:像第一種情況,一切正常
正如我所知錯誤150代表「請求的視頻的所有者不允許它在嵌入式播放器中播放」。但是我發現它在1,3,4情況下仍然有效,那麼它是什麼意思?
看到Vevo所有關於這個問題的視頻。我不確定Vevo是否定義了一些嵌入其視頻的政策。
也許問題來自我的域名music.com,但我不確定是否有一些規則的域名嵌入在網站上的Vevo的視頻。
如果我爲我的網站購買域名,那麼我得到錯誤150,這是如此糟糕。 :(
是否有任何人處理這之前,請給我一些解決方案,在此先感謝
注:。該錯誤只發生在VEVO的視頻
我不不要以爲你會能夠對Vevo的嵌入策略進行逆向工程。即使你這樣做,也不保證你的新域名也不會在晚些時候被列入黑名單。 –