AS3加载本地视频播放完,自动跳入下一帧
1个回答
展开全部
写了一个视频封装类,播放完成后会派发事件的,具体看附件例子
package com.set2get.as3.media
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.NetStatusEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
/**
* Video封装类
* @author 秋色烽火
*/
public class VideoObj extends Sprite
{
/** 视频播放完成事件 */
public static const PLAY_FINISH:String = "vplayfinish";
private var connection:NetConnection;
private var stream:NetStream;
private var video:Video
public function VideoObj()
{
video = new Video();
connection = new NetConnection();
connection.connect(null);
stream = new NetStream(connection);
video.attachNetStream(stream);
//stream.play(videoURL);
addChild(video);
seterror(); //容错
stream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
}
public function play($videoURL:String):void
{
stream.play($videoURL);
}
private function seterror():void {
var clientobj=new Object();
clientobj.onMetaData=function(){};
stream.client=clientobj;
}
private function onNetStatus(_evt:NetStatusEvent):void
{
switch(_evt.info.code) {
case "NetStream.Play.Stop":
//派发播放完成事件
dispatchEvent(new Event(VideoObj.PLAY_FINISH));
break;
}
}
public function destroy():void {
video.attachNetStream(null);
connection.close();
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询