请帮助我,我需要我的AS3 FLVPlayback组件顺序播放一个播放列表xml,这是无限期重复,直到我得到这个代码的那一刻,它只允许你选择你想播放的视频,但不要去下一次自动停止...
我非常感谢你的帮助,厄瓜多尔的问候
AS3代码:
var vlist:XML = new XML();
var XML_URL:String = "vids.xml";
var vlistURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(vlistURL);
myLoader.addEventListener(Event.COMPLETE, xmlLoaded);
function xmlLoaded(evtObj:Event) {
vlist = XML(myLoader.data);
for (var i=0; i<vlist.vid.length(); i++) {
vid_select.addItem({label:vlist.vid[i].@desc, data:vlist.vid[i].@url});
}
vlist.ignoreWhitespace = true;
vid.play(vid_select.getItemAt(0).data);
vid_select.selectedIndex = 0;
}
var vidList:Object = new Object();
function changeHandler(event:Event):void {
vid.play(vid_select.getItemAt(vid_select.selectedIndex).data);
}
vid_select.addEventListener(Event.CHANGE, changeHandler);
答案 0 :(得分:0)
您应该为VideoEvent.COMPLETE
FLVPlayback
实例添加一个监听器,一旦您的视频播放器到达其选定的视频流,就会调度该监听器。在那里,您可以从vid_select
中选择下一个视频并启动该视频的新播放。
答案 1 :(得分:0)
var vlist:XML = new XML();
var XML_URL:String = "vids.xml";
var vlistURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(vlistURL);
var currentVideo:Int = 0;
myLoader.addEventListener(Event.COMPLETE, xmlLoaded);
function xmlLoaded(evtObj:Event) {
vlist = XML(myLoader.data);
for (var i=0; i<vlist.vid.length(); i++) {
vid_select.addItem({label:vlist.vid[i].@desc, data:vlist.vid[i].@url});
}
vlist.ignoreWhitespace = true;
playVideo()
}
var vidList:Object = new Object();
function videoFinished(e:VideoEvent):void{
vid.removeEventListener(VideoEvent.COMPLETE,videoFinished);
currentVideo++
playVideo()
}
function playVideo(){
vid.play(vid_select.getItemAt(currentVideo % vlist.vid.length()).data);
vid_select.selectedIndex = currentVideo % vlist.vid.length();
vid.addEventListener(VideoEvent.COMPLETE,videoFinished);
}
function changeHandler(event:Event):void {
currentVideo = vid_select.selectedIndex;
playVideo();
}
vid_select.addEventListener(Event.CHANGE, changeHandler);