0
FLVPlayback組件和stop()play()方法存在問題。這裏是我的課程代碼,videoPlayer是舞臺上的FLVPlayback組件。該陣列以格式[videos/s1.flv,videos/s2.flv,videos/s3.flv]保存視頻當我在第一個視頻仍在播放時調用stopVideo()函數時,它將停止並倒回到第1幀視頻(按預期工作),但當我調用playVideo()方法時,它不再播放視頻。當我在播放第二或第三個視頻時停止FLVPlayback時,它可以正常工作。我知道READY事件在第一個視頻中沒有被調用,因爲它在開始時被調用。我做錯了什麼?FLVPlayback停止/播放
public class Intro extends MovieClip {
private var intros:XML;
private var currentVideo:uint = 0;
private var _data:XML;
private var videos:Array;
public function Intro(data:XML) {
_data = data;
videoPlayer.addEventListener(VideoEvent.COMPLETE, completeHandler);
videoPlayer.addEventListener(VideoEvent.READY, videoReady);
videoPlayer.opaqueBackground = 0x000000;
videoPlayer.autoRewind = true;
}
function completeHandler(evt:Event):void {
trace("video complete");
currentVideo++;
if (currentVideo < videos.length) {
videoPlayer.source = videos[currentVideo];
} else {
currentVideo = 0;
}
}
public function playVideo():void {
trace(currentVideo);
if (currentVideo == 0) {
trace(videos[currentVideo]);
videoPlayer.play(videos[currentVideo]);
} else {
videoPlayer.source = videos[currentVideo];
}
}
public function prepareVideos(introVideos:XML):void {
intros = introVideos;
var list:XMLList = intros.entry;
var entry:XML;
var len:int = list.length();
videos = new Array();
for (var i:int = 0; i < len; i++) {
entry = list[i];
videos.push(entry);
}
dispatchEvent(new Event(Event.COMPLETE));
}
public function stopVideo():void {
if (videoPlayer.playing) {
trace("video stopped");
videoPlayer.stop();
currentVideo = 0;
}
}
private function resetVideo(e:VideoEvent):void {
videoPlayer.seek(0);
}
private function videoReady(e:VideoEvent):void {
trace("video ready");
videoPlayer.play();
}
}