我如何检查 -> 视频是否被删除/私有或不允许嵌入?
演示: http: //jsbin.com/eyexah/15/edit
YT API 文档: https ://developers.google.com/youtube/js_api_reference
JS代码
var params = {
allowScriptAccess: "always"
},
atts = {
id: "youtube_player"
};
swfobject.embedSWF('http://www.youtube.com/v/SJmrqKOsIpM?enablejsapi=1&playerapiid=ytplayer&version=3&autoplay=1', 'youtube', '425', '356', '8', null, null, params, atts);
function onPlayerStateChange(e) {
if (e !== 1) {
return;
}
var availableQualityLevels = ytp.getAvailableQualityLevels();
console.log(availableQualityLevels);
}
function onYouTubePlayerReady() {
window.ytp = document.getElementById("youtube_player");
ytp.addEventListener('onStateChange', 'onPlayerStateChange')
};