FLVPlayback.close

Availability

Flash Player 8.

Edition

Flash Professional 8.

Usage

var listenerObject:Object = new Object();
listenerObject.close = function(eventObject:Object):Void {
    // insert event-handling code here
};
my_FLVplybk.addEventListener("close", listenerObject);

Description

Event; the FLVPlayback instance dispatches this event when it closes the NetConnection, by timing out or through a call to the closeVideoPlayer() method, or when you call the load() method or the play() method or set contentPath and cause the RTMP connection to close as a result. The FLVPlayback instance dispatches this event only when streaming from FMS or FVSS. The event object has the properties state and playheadTime.

Event has property vp, which is the index number of the video player to which this event applies.

Example

The following example assumes playing a streaming FLV file from a FMS or FVSS. When the FLV file completes, a listener for the complete event sets the contentPath property to the location of a new FLV file, which triggers a close event on the RTMP connection for the first FLV file. The listener for the close event displays the index number of the video player for which the event occurred.

Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline. In the statement that loads the contentPath property, replace the italicized text with the name and location of an FLV file on your FMS.

/**
 Requires:
  - FLVPlayback component on the Stage with an instance name of my_FLVPlybk
*/
import mx.video.*;
var listenerObject:Object = new Object();
// listen for close event on RTMP connection; display index of video player
listenerObject.close = function(eventObject:Object) {
    trace("Closed connection for video player: " + eventObject.vp);
};
my_FLVPlybk.addEventListener("close", listenerObject);
// listen for complete event; play new FLV
listenerObject.complete = function(eventObject:Object) {
    if (my_FLVPlybk.contentPath != "http://www.helpexamples.com/flash/video/water.flv") {
        my_FLVPlybk.play("http://www.helpexamples.com/flash/video/water.flv");
    }
};
my_FLVPlybk.addEventListener("complete", listenerObject);
my_FLVPlybk.contentPath = "rtmp://my_servername/my_application/stream.flv";

See also

FLVPlayback.activeVideoPlayerIndex, FLVPlayback.closeVideoPlayer(), FLVPlayback.contentPath, FLVPlayback.load(), FLVPlayback.play(), FLVPlayback.visibleVideoPlayerIndex,