Youtube api Youtube IFrame API onError为来自Vevo的视频触发,错误代码为150
让我解释一下我的情况。我想在我的网站上嵌入一些视频。 我在这个页面上用idwdgzbraw74()测试了视频:。它工作正常 我尝试以下示例代码:Youtube api Youtube IFrame API onError为来自Vevo的视频触发,错误代码为150,youtube-api,Youtube Api,让我解释一下我的情况。我想在我的网站上嵌入一些视频。 我在这个页面上用idwdgzbraw74()测试了视频:。它工作正常 我尝试以下示例代码: <!DOCTYPE html> <html> <body> <!-- 1. The <iframe> (and video player) will replace this <div> tag. --> <div id="player"></div> &
<!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>
// 2. 此代码异步加载IFrame播放器API代码。
var tag=document.createElement('script');
tag.src=“//www.youtube.com/iframe_api”;
var firstScriptTag=document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(标记,firstScriptTag);
// 3. 此函数用于创建(和YouTube播放器)
//API代码下载后。
var播放器;
函数onyoutubeiframeapiredy(){
player=新的YT.player('player'{
高度:“390”,
宽度:“640”,
videoId:'WDGZBRAW74',
活动:{
“onReady”:onPlayerReady,
“onStateChange”:onPlayerStateChange,
“onError”:OnPlayeError
}
});
}
// 4. 当视频播放器准备就绪时,API将调用此函数。
函数onPlayerReady(事件){
event.target.playVideo();
}
// 5. 当播放器的状态改变时,API调用此函数。
//该功能指示播放视频时(状态=1),
//玩家应该玩六秒钟,然后停下来。
var done=false;
函数onPlayerStateChange(事件){
如果(event.data==YT.PlayerState.PLAYING&&!done){
设置超时(停止视频,6000);
完成=正确;
}
}
函数onplayerror(事件){
console.log(事件数据);
}
函数stopVideo(){
player.stopVideo();
}
在我的本地主机上使用一些虚拟主机域,我得到了以下结果:
注意:此错误仅发生在Vevo的视频上。允许内容所有者设置允许/拒绝嵌入的域名的白/黑列表。无法绕过这些限制
这篇博文提供了更多关于内容限制的信息:我认为你无法对Vevo的嵌入策略进行反向工程。即使你这样做了,也不能保证你的新域名以后也不会被列入黑名单。谢谢杰夫!非常有用的信息,现在我完全知道我要对这个问题做什么了,过滤其余的ricted视频或查找其他解决方案博客帖子已移至