User Guide

50 Using Media Classes
The NetStream class
This section includes recommendations for optimizing your use of the NetStream class,
including tips on incorporating data into a stream, managing a streams buffer, and executing
code when a stream has finished playback.
Using multiple data types in a stream
In addition to streaming audio and video, you can include data, such as a text message, in a
stream. To add multiple data types to a stream, use the following method:
NetStream.send()
Getting the stream time length with ActionScript
If you are buffering your streams, you can use the NetStream.bufferLength property to get
the number of seconds currently in the buffer. Sometimes, however, you may want to get the
total length of a stream. Flash Player doesnt have this information, but Flash Media Server
does; the server has a
Stream.length property that the client can request through a message
to the server.
You can use client-side ActionScript such as the following to request the stream length:
function getInfo(){
nc.call("sendInfo", new MyResultSetName(), myStream);
}
function MyResultSetName(){
this.onResult = function(retVal){
_root.streamlength = retVal;
};
this.onStatus = function(info){
trace("Level: " + info.level + " Code: " + info.code);
// process error object
};
}