Flash Media Server Developer Documentation

Create a client-side playlist

This playlist uses names of streams that are stored on the server. To change the playlist, you need to change the code in your application client.

Note: Use the Streams sample, Streams.as, written in ActionScript 3.0.

  1. Create a NetConnection object, connect to the server, and add a netStatus event handler.
  2. Create a NetStream object and listen for netStatus events:
    private function createPlayList(nc:NetConnection):void {
        stream = new NetStream(nc);
        stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
        stream.client = new CustomClient();
        ...
    }
    
    
  3. Attach the NetStream object to a Video object:
        video = new Video();
        video.attachNetStream(stream);
    
    
  4. Define a series of play() methods on the NetStream object:
        stream.play( "advertisement", 0, 30 );
        stream.play( "myvideo", 10, -1, false );
        stream.play( "bikes", 0, -1, false );
        stream.play( "parade", 30, 120, false);
        addChild(video);
    }
    
    
  5. Listen for NetStream event codes in your netStatus event handler:
    private function netStatusHandler(event:NetStatusEvent):void
    {
        ...
        case "NetStream.Play.Stop":
            trace("The stream has finished playing");
            break;
        case "NetStream.Play.StreamNotFound":
            trace("The server could not find the stream"); 
            break;
    }
    
    

This playlist plays these streams:

  • A recorded stream named advertisement.flv, from the beginning, for 30 seconds
  • The recorded stream myvideo.flv, starting 10 seconds in, until it ends
  • The recorded stream bikes.flv, from start to end
  • The recorded stream parade.flv, starting 30 seconds in and continuing for 2 minutes