AS3 - 视频完成事件 [英] AS3 - Video complete event
本文介绍了AS3 - 视频完成事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何触发一个事件,如果视频是结束了吗? I'ld喜欢展示一个重放按钮即可。
How to trigger an event if the video is over? I'ld like to show a replay button then.
var vid:Video = new Video(480, 270);
vidcont.addChild(vid);
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
vid.attachNetStream(ns);
var listener:Object = new Object();
listener.onMetaData = function(evt:Object):void {};
ns.client = listener;
function playVideo(e:Event = null) {
ns.play("sneak.flv");
}
谢谢 乌利
推荐答案
添加 NetStatusEvent.NET_STATUS
事件对你的的NetStream
对象,并检查了NetStream.Play.Stopcode。
Add the NetStatusEvent.NET_STATUS
event on your NetStream
object and check for the "NetStream.Play.Stop" code.
例如:
var ns:NetStream = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
然后创建处理方法:
Then create the handler method:
private function netStatusHandler(evt:NetStatusEvent):void {
if (evt.info.code == "NetStream.Play.Stop") {
// do loop...
}
}
如果您需要检查多个code,它的更好,如果使用的开关情况吧。
If you need to check more than one code, it's better to use a switch case instead of an if.
这篇关于AS3 - 视频完成事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文