有时候,需要按顺序播放多个FLV视频段落,一个接着一个播放,在一个FLV文件播放结束时,等待播放另一个FLV文件,此时如果处理不好就会停顿,以下以FlashCS3(AS 3.0)说明一下。
假设舞台上有一个id是Flvp的FLVplayback对象,FLVplayback类提供了两个属性:activeVideoPlayerIndex和visibleVideoPlayerIndex
activeVideoPlayerIndex处理LOAD方法,visibleVideoPlayerIndex处理play方法。
利用属性activeVideoPlayerIndex和visibleVideoPlayerIndex指定多个FLV播放器,就可实现FLV播放无缝衔接。
以下是代码:
import fl.video.MetadataEvent;
import fl.video.VideoEvent;
this.Flvp.skin="key/SkinUnderPlayStopSeekMuteVol.swf";
this.Flvp.volume=0.2;
Flvp.width=320;
Flvp.height=256;
Flvp.x=132.3;
Flvp.y=56;
this.Flvp.load("[url=file:///D|/My]file:///D|/My[/url] Documents/Echo/尼克·波利泰尼网球教程/1-致命正手/1.1-致命正手.flv");
Flvp.addEventListener(fl.video.VideoEvent.COMPLETE,Flvpcomplete);
Flvp.addEventListener(fl.video.MetadataEvent.CUE_POINT,Flvpvuepoint);
//增加AS提示点,利用提示点事件触发LOAD第二段FLV视频
var cuePt:Object = new Object();
cuePt.time = 400;
cuePt.name = "elapsed_time";
cuePt.type = "actionscript";
Flvp.addASCuePoint(cuePt);
function Flvpcomplete(eveObj:fl.video.VideoEvent):void {
this.Flvp.activeVideoPlayerIndex=1;
this.Flvp.visibleVideoPlayerIndex=1;
Flvp.play();
this.Flvp.volume=0.21;
}
function Flvpvuepoint(eveObj:fl.video.MetadataEvent):void {
trace(eveObj.info.name);
this.Flvp.activeVideoPlayerIndex=1;
this.Flvp.source="[url=file:///D|/My]file:///D|/My[/url] Documents/Echo/尼克·波利泰尼网球教程/1-致命正手/1.2-致命正手.flv";
this.Flvp.activeVideoPlayerIndex=0;
}