Playing a sequence of videos

With the rise of Flash Video, it is no wonder that some people are wondering if they can play through a folder containing a number of FLV files. The answer is you can. The the truthful answer is you can if you have a Flash Media Server account.

It really isn't terribly difficult to accomplish. In the swf, each video plays for 10 seconds and the next one flames up. How that happens is through the parameters in the Play() method in a NetStream. You can add a couple more parameters than just the name of the video to play. The syntax is ns.play(name,start,length,reset). In the following code you will see that the video plays for 10 seconds and only the first one plays again, once the others have finished.

Here's the code that drives it:

var myVid:Video;

var nc:NetConnection = new NetConnection();
nc.connect("rtmp://localhost/Trailers/_definst_");
var ns:NetStream = new NetStream(nc);

myVid.attachVideo(ns);
ns.play("Trail01",0,10,true);
ns.play("Trail02",0,10,false);
ns.play("Trail03",0,10,false);
ns.play("Trail04",0,10,false);
ns.play("Trail05",0,10,false);
ns.play("Trail06",0,10,false);

This code shows how to play back from a Flash Media Serve - localhost- that is installed on your machine. You would replace localhost with the address of your FMS2 account. The address would look like this:rtmp:// 123.45.678.90/Trailer/_definst_ .

Flash Communication Server provided by:

Creative Commons logo