Recipe 14.8 Creating Playlists

14.8.1 Problem

You want to create a playlist in which streams are queued and played one after another.

14.8.2 Solution

Use the ) method to add streams to the playlist. Specify false for the flushPlaylists parameter.

14.8.3 Discussion

You can create playlists for net streams relatively quickly and easily with built-in functionality. The ) method allows you to create playlists by simply appending new streams with each subsequent play( ) invocation. However, the default behavior is for play( ) to flush the current playlist. To avoid flushing the existing playlist, specify false for the optional fourth parameter, flushPlaylists. You can use -2 and -1 as placeholders for the intervening start and length parameters to maintain the default behavior:

// Add three streams to a net stream object's playlist."stream0", -2, -1, false);"stream1", -2, -1, false);"stream2", -2, -1, false);

Flash automatically begins playback of the next stream in the playlist when the current stream stops, which depends on the values specified for the start and length parameters. These parameters are discussed in Recipe 14.7.

You can create a new playlist at any time by calling play( ) with a value of true for the flushPlaylists parameter. This flushes the current playlist, stops the current stream, and plays the new stream."stream3", -2, -1, true);

Omitting the fourth parameter performs the same operation:"stream3", -2, -1);

    Part I: Local Recipes
    Part II: Remote Recipes