Flash Media Server Developer Documentation

NetStream.onStatus()

public onStatus = function(infoObject:Object) {}

Invoked every time a status change or error is posted for the NetStream object. If you want to respond to this event handler, you must create a function to process the information object sent by the server.

In addition to this NetStream.onStatus() handler, Flash Player also provides a super function called System.onStatus(). If NetStream.onStatus() is invoked for a particular object and no function is assigned to respond to it, Flash Player processes a function assigned to System.onStatus() if it exists.

Availability

Flash Communication Server 1.0; Flash Player 6.

Parameters

infoObject An object with code and level properties that provide information about the status of a NetStream object, as follows:

code property

level property

Meaning

NetStream.Buffer.Empty

status

Data is not being received quickly enough to fill the buffer. Data flow is interrupted until the buffer refills, at which time a NetStream.Buffer.Full message is sent and the stream begins playing again.

NetStream.Buffer.Full

status

The buffer is full and the stream begins playing.

NetStream.Buffer.Flush

status

Data has finished streaming, and the remaining buffer will be emptied.

NetStream.Failed

error

An error has occurred for a reason other than those listed elsewhere in this table, such as the subscriber trying to use the seek command to move to a particular location in the recorded stream, but with invalid parameters.

NetStream.Pause.Notify

status

The subscriber has paused playback.

NetStream.Play.FileStructureInvalid

error

Flash Player detects an invalid file structure and will not try to play this type of file. Supported by Flash Player 9 Update 3 and later.

NetStream.Play.NoSupportedTrackFound

error

Flash Player does not detect any supported tracks (video, audio or data) and will not try to play the file. Supported by Flash Player 9 Update 3 and later.

NetStream.Play.Failed

error

An error has occurred in playback for a reason other than those listed elsewhere in this table, such as the subscriber not having read access.

This information object also has a description property, which is a string that provides a more specific reason for the failure.

NetSream.Play.InsufficientBW

warning

Data is playing behind the normal speed.

NetStream.Play.PublishNotify

status

Publishing has begun; this message is sent to all subscribers.

NetStream.Play.Reset

status

The playlist has reset (pending play commands have been flushed).

NetStream.Play.Start

status

Playback has started. This information object also has a details property, a string that provides the name of the stream currently playing on the NetStream. If you are streaming a playlist that contains multiple streams, this information object is sent each time you begin playing a different stream in the playlist.

NetStream.Play.Stop

status

Playback has stopped. This message is sent from the server.

NetStream.Play.StreamNotFound

error

The client tried to play a live or recorded stream that does not exist.

NetStream.Play.UnpublishNotify

status

Publishing has stopped; this message is sent to all subscribers.

NetStream.Publish.BadName

error

The client tried to publish a stream that is already being published by someone else.

NetStream.Publish.Idle

status

The publisher of the stream has been idle for too long.

NetStream.Publish.Start

status

Publishing has started.

NetStream.Record.Failed

error

An error has occurred in recording for a reason other than those listed elsewhere in this table; for example, the disk is full.

This information object also has a description property, which is a string that provides a more specific reason for the failure.

NetStream.Record.NoAccess

error

The client tried to record a stream that is still playing, or the client tried to record (overwrite) a stream that already exists on the server with read-only status.

NetStream.Record.Start

status

Recording has started.

NetStream.Record.Stop

status

Recording has stopped.

NetStream.Seek.Failed

error

The subscriber tried to use the seek command to move to a particular location in the recorded stream, but failed.

NetStream.Seek.Notify

status

The subscriber has used the seek command to move to a particular location in the recorded stream.

NetStream.Unpause.Notify

status

The subscriber has resumed playback.

NetStream.Unpublish.Success

status

Publishing has stopped.

Example

The following example displays data about the stream in the Output panel:

var connection_nc:NetConnection = new NetConnection();
connection_nc.connect("rtmp://someServer/someApp");
var stream_ns:NetStream = new NetStream(connection_nc);
my_video.attachVideo(stream_ns);
stream_ns.play("video1");
stream_ns.onStatus = function(infoObject:Object) {
    trace("NetStream.onStatus called: ("+getTimer()+" ms)");
    for (var prop in infoObject) {
        trace("\t"+prop+":\t"+infoObject[prop]);
    }
    trace("");
};