AS3.0加载FLV视频的方法及实现代码
程序员文章站
2022-10-06 15:52:30
AS3.0加载FLV视频,有些新手朋友可能会很陌生,本文详细整理了一些实用方法,需要了解的朋友可以参考下... 12-12-31...
复制代码
代码如下://打开连接
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;
}