复制代码
代码如下://打开连接
var nc:NetConnection = new NetConnection();
nc.connect (null);
//提取 flv视频
var ns:NetStream = new NetStream(nc);
ns.play ("laislabonita.flv");
//显示 flv视频
var vid:Video = new Video();
vid.attachNetStream (ns);
addChild (vid);
//处理错误
ns.addEventListener (AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
function asyncErrorHandler (event:AsyncErrorEvent):void
{
// 忽略错误
}
///控制影片暂停/播放
function mouseRelease (event:MouseEvent)
{
ns.togglePause ();
}
pause_btn.addEventListener (MouseEvent.CLICK,mouseRelease);
补充:
复制代码
代码如下://onMetaData
var client:Object=new Object();
client.onMetaData = onMetaData;
videoStream.client = client;
function onMetaData(data:Object):void
{
_duration = data.duration;
}