我正在为我的荣誉项目开发一个 Flash Web 应用程序 (Actionscript 2.0),但在嵌入 youtube 视频时遇到了麻烦。基本上,用户根据所选符号选择带有特定标签的 youtube api 查询符号,然后从前 30 个视频中挑选一个随机视频。我使用以下代码进行此工作:
on (release) {
url="http://gdata.youtube.com/feeds/api/videos?q=danger+passion&orderby=published&start-index="+random(30)+"&max-results=1&v=2"
getURL(url);
}
但这只是显示一个带有 youtube 视频链接的网页。
这是我将用作播放器基础的代码:
// create a MovieClip to load the player into
var ytplayer:MovieClip = _root.createEmptyMovieClip("ytplayer", 1);
// create a listener object for the MovieClipLoader to use
var ytPlayerLoaderListener:Object = {
onLoadInit: function() {
// When the player clip first loads, we start an interval to
// check for when the player is ready
loadInterval = setInterval(checkPlayerLoaded, 250);
}
};
var loadInterval:Number;
function checkPlayerLoaded():Void {
// once the player is ready, we can subscribe to events, or in the case of
// the chromeless player, we could load videos
if (ytplayer.isPlayerLoaded()) {
ytplayer.addEventListener("onStateChange", onPlayerStateChange);
ytplayer.addEventListener("onError", onPlayerError);
clearInterval(loadInterval);
}
}
function onPlayerStateChange(newState:Number) {
trace("New player state: "+ newState);
}
function onPlayerError(errorCode:Number) {
trace("An error occurred: "+ errorCode);
}
// create a MovieClipLoader to handle the loading of the player
var ytPlayerLoader:MovieClipLoader = new MovieClipLoader();
ytPlayerLoader.addListener(ytPlayerLoaderListener);
// load the player
ytPlayerLoader.loadClip("http://www.youtube.com/v/pv5zWaTEVkI", ytplayer);
谁能帮我从提要中获取视频的 ID(例如:pv5zWaTEVkI)?或者如何从 Flash 发送查询,该查询将返回视频 url/id,而不是 feed 的 url。任何帮助将不胜感激,因为我很快就会介入。谢谢