User Guide
Playing multiple FLV files 521
Playing multiple FLV files
You can play FLV files sequentially in an FLVPlayback instance simply by loading a new URL
in the
contentPath property when the previous FLV file finishes playing. For example, the
following ActionScript code listens for the
complete event, which occurs when an FLV file
finishes playing. When this event occurs, the code sets the name and location of a new FLV
file in the
contentPath property and calls the play() method to play the new video.
import mx.video.*;
my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/
clouds.flv";
var listenerObject:Object = new Object();
// listen for complete event; play new FLV
listenerObject.complete = function(eventObject:Object):Void {
if (my_FLVPlybk.contentPath == "http://www.helpexamples.com/flash/video/
clouds.flv") {
my_FLVPlybk.play("http://www.helpexamples.com/flash/video/water.flv");
}
};
my_FLVPlybk.addEventListener("complete", listenerObject);
Using multiple video players
You can also open multiple video players within a single instance of the FLVPlayback
component to play multiple videos and switch between them as they play.
You create the initial video player when you drag the FLVPlayback component to the Stage.
The component automatically assigns the initial video player the number 0 and makes it the
default player. To create an additional video player, simply set the
activeVideoPlayerIndex
property to a new number. Setting the
activeVideoPlayerIndex property also makes the
specified video player the active video player, which is the one that will be affected by the
properties and methods of the FLVPlayback class. Setting the
activeVideoPlayerIndex
property does not make the video player visible, however. To make the video player visible, set
the
visibleVideoPlayerIndex property to the video player’s number. For more information
on how these properties interact with the methods and properties of the FLVPlayback class,
see
FLVPlayback.activeVideoPlayerIndex on page 549 and
FLVPlayback.visibleVideoPlayerIndex on page 688.