Flash AS3 中的 XML-Youtube 视频
我正在制作一个播放器,它可以调用来自 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
之后
这里是一个很好的在线教程。就通过它吧。
after that
Here is a good online tut. Just go through it.