YouTube видео не загружается по id
Я получил код с игровой площадки кода http://code.google.com/apis/ajax/playground/?exp=youtube
я не знаю, почему это не работает на моем компьютере
'<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>YouTube Player API Sample</title>
<style type="text/css">
#videoDiv {
margin-right: 3px;
}
#videoInfo {
margin-left: 3px;
}
</style>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load("swfobject", "2.1");
</script>
<script type="text/javascript">
/*
* Change out the video that is playing
*/
// Update a particular HTML element with a new value
function updateHTML(elmId, value) {
document.getElementById(elmId).innerHTML = value;
}
// Loads the selected video into the player.
function loadVideo() {
var selectBox = document.getElementById("videoSelection");
var videoID = selectBox.options[selectBox.selectedIndex].value
if(ytplayer) {
ytplayer.loadVideoById(videoID);
}
}
// This function is called when an error is thrown by the player
function onPlayerError(errorCode) {
alert("An error occured of type:" + errorCode);
}
// This function is automatically called by the player once it loads
function onYouTubePlayerReady(playerId) {
ytplayer = document.getElementById("ytPlayer");
ytplayer.addEventListener("onError", "onPlayerError");
}
// The "main method" of this sample. Called when someone clicks "Run".
function loadPlayer() {
// The video to load
var videoID = "ylLzyHk54Z0"
// Lets Flash from another domain call JavaScript
var params = { allowScriptAccess: "always" };
// The element id of the Flash embed
var atts = { id: "ytPlayer" };
// All of the magic handled by SWFObject (http://code.google.com/p/swfobject/)
swfobject.embedSWF("http://www.youtube.com/v/" + videoID +
"&enablejsapi=1&playerapiid=player1",
"videoDiv", "480", "295", "8", null, null, params, atts);
}
function _run() {
loadPlayer();
}
google.setOnLoadCallback(_run);
</script>
Loading...
Выберите видео для загрузки:
Обзор API YouTube Ninja Cat Beatboxing Flute '1 ответ
Из Google Chromeless API:
Примечание. Чтобы проверить любой из этих вызовов, ваш файл должен быть запущен на веб-сервере, поскольку проигрыватель Flash Player ограничивает вызовы между локальными файлами и Интернетом. [1]
Почему бы вам не попробовать онлайн демо? [2]
[1] http://code.google.com/apis/youtube/js_api_reference.html
[2] http://code.google.com/apis/youtube/youtube_player_demo.html?playerType=chromeless&playerVersion=as3