AS3.0加载FLV视频的方法及实现代码
网站建设 2021-07-03 14:34www.dzhlxh.cn网站建设
复制代码
代码如下://打开连接
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;
}
上一篇:如何将3Dmax的设置恢复成默认状态
下一篇:as3 加载外部声音文件问题详细剖析