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 stream’s 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 doesn’t 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
};
}
Summary of Contents for FLASH MEDIA SERVER 2-DEVELOPING MEDIA
Page 1: ...Developing Media Applications ...
Page 6: ...6 ...
Page 10: ...10 About This Manual ...
Page 36: ...36 Flash Media Server Architecture ...
Page 80: ...80 Debugging and Monitoring Applications ...
Page 106: ...106 Application Development Tips and Tricks ...
Page 114: ...114 ...