video播放代码

[code]
package {
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.display.MovieClip;
import flash.events.AsyncErrorEvent;
import flash.events.NetStatusEvent;
public class PlayFlv extends MovieClip {
private var flvVideo:Video;
private var flvURL:String;
private var flvNetCon:NetConnection;
private var flvNetStr:NetStream;
public function loadFlv(url:String) {
var flvObject:Object=new Object();
flvURL=url;
flvNetCon=new NetConnection();
flvNetCon.connect(null);
flvNetStr=new NetStream(flvNetCon);
flvNetStr.addEventListener(AsyncErrorEvent.ASYNC_ERROR,LoadErrot);
flvNetStr.addEventListener(NetStatusEvent.NET_STATUS,CurrentState);
flvNetStr.client=flvObject;
flvNetStr.play(flvURL);
flvVideo=new Video();
flvVideo.attachNetStream(flvNetStr);

flvNetStr.pause();
addChild(flvVideo);

}

public function setWH(_w:Number,_h:Number):void
{
flvVideo.width = _w;
flvVideo.height = _h;
}

private function LoadErrot(evt:AsyncErrorEvent):void {
//trace(evt.text);
}
private function CurrentState(evt:NetStatusEvent):void {
//trace(evt.info.code);
if (evt.info.code=="NetStream.Record.Stop")
//if (evt.info.code=="NetStream.Buffer.Empty")//放完重播放
{
trace("play over");
rback();
playflv1();
}
}
public function pauseflv1():void {
flvNetStr.pause();
}
public function playflv1():void {
flvNetStr.resume();
}
public function delflv1():void {
flvNetStr.close();
}
public function playstream1():void {
flvNetStr.togglePause();//自动在停止和播放之间切换
}
public function rback():void {
flvNetStr.play(flvURL);
}
}
}
[/code]