FLV 播放 AS3 播放列表序列
FLV Playback AS3 Playlist Sequence
请帮帮我,我需要我的 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);
您应该为 VideoEvent.COMPLETE
添加一个侦听器到您的 FLVPlayback
实例,一旦您的视频播放器到达其 selected 视频流的结尾,就会调度该侦听器。在那里,您可以 select 您的 vid_select
中的下一个视频并启动该视频的新播放。
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);
请帮帮我,我需要我的 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);
您应该为 VideoEvent.COMPLETE
添加一个侦听器到您的 FLVPlayback
实例,一旦您的视频播放器到达其 selected 视频流的结尾,就会调度该侦听器。在那里,您可以 select 您的 vid_select
中的下一个视频并启动该视频的新播放。
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);