flash通过xml加载视频要怎么做啊~~~~~
展开全部
1. xml文件,<root>
<video>
<url>xxx<url>
</video>
</root>
2. Flash中加载xml。
package {
import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.events.Event;
import flash.net.URLRequest;
public class Weather extends MovieClip {
private var xmlloader:URLLoader;
private var xml:XML;
private var videourl:String;
private var rand:Number = Math.random();
private var urlweather:String = "http://flash.weather.com.cn/xml/upload.xml?rand="+rand";
//private var urlweather:String = "upload.xml";
public function Weather() {
xmlloader = new URLLoader();
xmlloader.load(new URLRequest(urlweather));
xmlloader.addEventListener(Event.COMPLETE,onCompleteXml);
}
private function onCompleteXml(e:Event):void
{
xml = XML(e.target.data);
/ /trace(xml)
var xmllist:XMLList = xml.elements();
var lengths:int = xmllist.length();
videourl = xmllist[0].url; //
}
}
// 视屏代码、
videoSprite = new Sprite();
movieObj = new Object();
netConnection = new NetConnection();
netConnection.connect(null);
netStream = new NetStream(netConnection);
customClient= {onMetaData:metaDataHandler};
netStream.client = customClient;
netStream.play(videourl); //此videourl变量xml中的视屏路径地址。
netStream.addEventListener(NetStatusEvent.NET_STATUS, statusHandler);
video = new Video(598,336);
video.attachNetStream(netStream);
videoSprite.addChild(video);
this.addChild(videoSprite);
}
关于视屏的各种控制我就不写了。
<video>
<url>xxx<url>
</video>
</root>
2. Flash中加载xml。
package {
import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.events.Event;
import flash.net.URLRequest;
public class Weather extends MovieClip {
private var xmlloader:URLLoader;
private var xml:XML;
private var videourl:String;
private var rand:Number = Math.random();
private var urlweather:String = "http://flash.weather.com.cn/xml/upload.xml?rand="+rand";
//private var urlweather:String = "upload.xml";
public function Weather() {
xmlloader = new URLLoader();
xmlloader.load(new URLRequest(urlweather));
xmlloader.addEventListener(Event.COMPLETE,onCompleteXml);
}
private function onCompleteXml(e:Event):void
{
xml = XML(e.target.data);
/ /trace(xml)
var xmllist:XMLList = xml.elements();
var lengths:int = xmllist.length();
videourl = xmllist[0].url; //
}
}
// 视屏代码、
videoSprite = new Sprite();
movieObj = new Object();
netConnection = new NetConnection();
netConnection.connect(null);
netStream = new NetStream(netConnection);
customClient= {onMetaData:metaDataHandler};
netStream.client = customClient;
netStream.play(videourl); //此videourl变量xml中的视屏路径地址。
netStream.addEventListener(NetStatusEvent.NET_STATUS, statusHandler);
video = new Video(598,336);
video.attachNetStream(netStream);
videoSprite.addChild(video);
this.addChild(videoSprite);
}
关于视屏的各种控制我就不写了。
来自:求助得到的回答
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询