Flash AS3 中的 XML-Youtube 视频

发布于 2024-12-02 13:04:54 字数 1233 浏览 1 评论 0原文

我正在制作一个播放器,它可以调用来自 youtube.com 的视频并将其显示在我的 Flash 播放组件中。该脚本可以很好地加载视频,但是当我希望 Flash 从外部 XML 数据源加载相同的视频 ID 时,它会加载 YouTube 播放器 API,但不会加载视频。这是代码

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();

}

此脚本从 youtube.com 加载视频,其中包含我稍后定义的特定 ID

my_player.cueVideoById("53OyPYa7SEI",0)

和名为“videos.xml”的 XML 文件,我在其中传递了 youtube 链接并尝试从该 xml 文件调用视频在闪光中。但问题就在那里。这是 xml 代码

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

谁能帮我从 XML 文件中调用视频?

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-1" ?>
<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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

少女的英雄梦 2024-12-09 13:04:54
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);
}

之后

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

这里是一个很好的在线教程。就通过它吧。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文