I seem to be stuck in a perpetual loop here and need some help getting out of it. I place all my video that I want to play in an array videoPaths. I play the first video and when it is done I need to play the next one in the array and so on until all the videos have played.
In my netStatusHandler I am listening for when the video has stopped playing NetStream.Play.Stop. If the player has stopped, then I call a function playNextVideo, and thats where I am having trouble. How to play the next video in the array. How do I write the nextPlayVideo function. It seems like I need to loop through things again but I am not sure.
var vidSource:String;
var videoPaths:Array = new Array();
function videoList(categoryName:String, loadUrls:XMLList):void {
if (categoryName=="Our Services") {
trace("Top level:", categoryName);
for (var i:int = 0; i < loadUrls.length(); i++) {
//trace(loadUrls*);//vidSource URL's
videoPaths.push(loadUrls*);
vidSource=videoPaths[0];
//trace(vidSource);
}
}
}
function playVideos(vidSource):void {
trace(vidSource);
trace("video currently playing :", vidSource);
outText.appendText("
"+ vidSource);
stream_ns.play(vidSource);
}
function playNextVideo(vidSource):void {
}
// Set the function for what happens when that button gets clicked
function clipClick(e:Event):void {
outText.text=e.target.clickToPage;
if (e.target.clickToPage=="Our Services") {
//play video list
if(vidPlaying == "false"){
playNextVideo(vidSource)
}else{
playVideos(vidSource);
}
container.visible=true;
}
}
function netStatusHandler(p_evt:NetStatusEvent):void {
if (p_evt.info.code=="NetStream.FileStructureInvalid") {
trace("The MP4's file structure is invalid.");
} else if (p_evt.info.code == "NetStream.NoSupportedTrackFound") {
trace("The MP4 doesn't contain any supported tracks");
}
if (p_evt.info.code=="NetStream.Play.Start") {
vidPlaying=true;
trace(vidPlaying);
} else if (p_evt.info.code=="NetStream.Play.Stop") {
vidPlaying=false;
trace(vidPlaying);
playNextVideo(vidSource);
}
}