天天看點

flash as3 android air 插入視訊,用Flash AS3代碼實作多FLV視訊播放無縫銜接

有時候,需要按順序播放多個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;

}