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;
}

Copyright © 2016-2025 www.dzhlxh.cn 金源码 版权所有 Power by

网站模板下载|网络推广|微博营销|seo优化|视频营销|网络营销|微信营销|网站建设|织梦模板|小程序模板