我在网上找到了这个代码,它几乎完全符合我的需求 - 但是我需要它来连续循环剪辑。
var so: Sound= new Sound();
var audioChannel: SoundChannel= new SoundChannel();
var audioTransform: SoundTransform = new SoundTransform();
var video:Video=new Video(320,240);
var nc:NetConnection=new NetConnection ;
nc.connect(null);
var ns:NetStream=new NetStream(nc);
var meta: Object = new Object();
meta.onMetaData = function(meta:Object){
trace(meta.duration);
};
ns.client=meta;
addChild(video);
video.attachNetStream(ns);
ns.play("vid.flv");
//clip is a transparent clip (alpha=0) for the entire scene
clip.addEventListener(MouseEvent.MOUSE_OVER,mute);
clip.addEventListener(MouseEvent.MOUSE_OUT,unmute);
function mute(e:MouseEvent) {
ns.soundTransform=audioTransform;
audioTransform.volume=0;
}
function unmute(e:MouseEvent) {
ns.soundTransform=audioTransform;
audioTransform.volume=1;
}
答案 0 :(得分:0)
在AS3中循环视频流:
收听流NET_STATUS事件。
//ns is a netstream object
ns.addEventListener(NetStatusEvent.NET_STATUS, streamStatus);
在streamStatus
事件处理程序中,检查状态代码是否为视频停止事件:
function streamStatus(status:NetStatusEvent) {
if (status.info.code == "NetStream.Play.Stop") {
//the video has stopped
}
}
要循环播放视频,只需寻找开头。
ns.seek(0);
所以这是最终的代码:
ns.addEventListener(NetStatusEvent.NET_STATUS, streamStatus);
ns.play("vid.flv");
function streamStatus(status:NetStatusEvent) {
if (status.info.code == "NetStream.Play.Stop") {
ns.seek(0);
}
}
要查看您可以查看的状态代码,请参阅documentation。