通过 XML 在 Flash 中调用 Youtube.com 的视频
我正在尝试在 flash as2 中调用来自 youtube.com 的视频。视频链接存储在外部 xml 文件中。当我尝试调用具有确切 flv 位置的视频时,Flash 工作正常,但每当我尝试调用 YouTube 网址时,Flash 就会崩溃。我被代码困住了。我想知道视频是否可以在需要存储在 xml 中的特定 GMT 开始。请帮忙。
这是 flash 代码:
Security.allowDomain("www.youtube.com");
Security.allowDomain("*");
//initializing xml loading
// load the xml file
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("videos.xml");
// parse the nodes of the xml into an array
function loadXML() {
vidArray = new Array();
aNode = this.firstChild.childNodes;
len = aNode.length;
for (var n = 0; n != len; n++) {
vidArray[n] = aNode[n].attributes.url;
}
}
output_vid.onEnterFrame = function() {
trace(vidArray[0]);
output_vid.contentPath = vidArray[0];
};
这是 xml 代码 (video.xml)
<?xml version="1.0" encoding="ISO-8859-1" ?>
<videos>
<video url="http://www.youtube.com/watch?v=jYa1eI1hpDE"/>
</videos>
请帮忙!!
I am trying to call a video from youtube.com in flash as2. The video link is stored in a external xml file. Flash works fine when i try to call a video with an exact flv location but it crashes whenever i try to call a youtube url. I am stuck with the codes. I was wondering if the video can start at a specific GMT that needs to be stored in xml. Please help.
Here is the flash code:
Security.allowDomain("www.youtube.com");
Security.allowDomain("*");
//initializing xml loading
// load the xml file
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("videos.xml");
// parse the nodes of the xml into an array
function loadXML() {
vidArray = new Array();
aNode = this.firstChild.childNodes;
len = aNode.length;
for (var n = 0; n != len; n++) {
vidArray[n] = aNode[n].attributes.url;
}
}
output_vid.onEnterFrame = function() {
trace(vidArray[0]);
output_vid.contentPath = vidArray[0];
};
and here is the xml code (video.xml)
<?xml version="1.0" encoding="ISO-8859-1" ?>
<videos>
<video url="http://www.youtube.com/watch?v=jYa1eI1hpDE"/>
</videos>
Please help !!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 XML 加载到闪存中...
以字符串形式获取您的网址,例如“string3”..
string3 =“http://www.youtube.com/watch?v=jYa1eI1hpDE”
现在将“watch?v=”替换为“v/”
string3 = “http://www.youtube.com/v/jYa1eI1hpDE”
这是所有 YouTube 视频上的确切 flv 位置......无需执行任何其他操作。
Load the XML into flash...
Get your url in a string, say "string3" for example..
string3 = "http://www.youtube.com/watch?v=jYa1eI1hpDE"
now replace "watch?v=" with "v/"
now string3 = "http://www.youtube.com/v/jYa1eI1hpDE"
That is the exact flv location on all youtube videos.... no need to do anything else.