AS3.0加载FLV视频的方法及实现代码

平面设计 2021-07-03 14:34www.168986.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;
}

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by