开发者

XML-Youtube video in flash AS3

I was making a player which calls videos from youtube.com and displays it in my flash playback component. The script loads the videos fine but when i want the flash to load the same video ID from an external XML data source, it loads the youtube player API but not the video. Here is the code

Security.allowDomain("www.youtube.com");
Security.allowDomain("*");
var my_player:Object;

var my_loader:Loader = new Loader();
my_loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
my_loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);

function onLoaderInit(e:Event):void {
    addChild(my_loader);
    my_player = my_loader.content;
    my_player.addEventListener("onReady", onPlayerReady);
}

function onPlayerReady(e:Event):void {
    my_player.setSize(582.2,373.1);
    my_player.cueVideoById("53OyPYa7SEI",0);
    my_player.playVideo();

}

This script loads the video from youtube.com with an specific ID which i have defined at

my_player.cueVideoById("53OyPYa7SEI",0)

later i defined and XML file called "videos.xml" where i passed the youtube link and tried to call the video from that xml file in flash. But the problem comes there. Here is the xml code

<?xml version="1.0" encoding="ISO-8859-开发者_StackOverflow1" ?>
<videos>
<VIDEO url="http://www.youtube.com/watch?v=53OyPYa7SEI" id=1/>
<VIDEO url="http://www.youtube.com/watch?v=53OyPYa7SEI" id=2/>
</videos>

Can anyone help me out to call the video from an XML file?


var XMLPath:String = "videos.xml";
var xmlSlideshow :XML;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, onXMLLoadComplete);
//xmlLoader.addEventListener(ProgressEvent.PROGRESS, xmlLoadingAction);
//xmlLoader.addEventListener(ErrorEvent.ERROR,ErrorAction);
xmlLoader.load(new URLRequest(XMLPath));

function onXMLLoadComplete(e:Event):void {
    xmlSlideshow = new XML(e.target.data);
    trace(xmlSlideshow.VIDEO.@url);
}

after that

my_loader.load(new URLRequest(xmlSlideshow.VIDEO.@url));

Here is a good online tut. Just go through it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜