|
|
Регистрация Восстановить пароль |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
|
Опции темы | Поиск в этой теме |
25.06.2011, 09:54 | #1 |
Пользователь
Регистрация: 04.02.2011
Сообщений: 23
|
Реализация включения видео с youtube
Здравствуйте Уважаемые кодеры
есть скрипт включения видео через выборку <select><option></option></select> вот код в целом Код HTML:
<!-- You are free to copy and use this sample in accordance with the terms of the Apache license (http://www.apache.org/licenses/LICENSE-2.0.html) --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <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&autoplay=1", "videoDiv", "480", "295", "8", null, null, params, atts); } function _run() { loadPlayer(); } google.setOnLoadCallback(_run); </script> </head> <body style="font-family: Arial;border: 0 none;"> <table> <tr> <td><div id="videoDiv">Loading...</div></td> <td valign="top"> <div id="videoControls"> <p>Select a video to load:</p> <select id="videoSelection" onchange="loadVideo();"> <option value="ylLzyHk54Z0" selected>YouTube API Overview</option> <option value="GMUlhuTkM3w">Beatboxing Flute</option> </select> </div> </td></tr> </table> </body> </html> Ребята помогите пожалуйста реализовать выборку через тег <a> к примеру <a href="">Велосипед</a> <a href="">Машина</a> |
26.06.2011, 06:23 | #2 |
Раздолбайских Дел
Старожил
Регистрация: 22.05.2009
Сообщений: 3,828
|
Передавайте в videoID напрямую значения из соответствующих option-ов. А в самой функции уберите получение этого "videoID" из селекта.
Alar, верни репу!
|
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
Ссылка на видео с Youtube | stepennwolf | PHP | 0 | 23.04.2011 00:10 |
Стражи включения | mansp | Общие вопросы C/C++ | 15 | 13.02.2011 20:00 |
Время включения компьютеров | J-Max | Компьютерное железо | 8 | 27.12.2010 22:19 |