
ADOBE FLASH MEDIA INTERACTIVE SERVER
Server-Side ActionScript Language Reference
104
length A number indicating the length of play, in seconds. For a live stream, a value of -1 plays the stream as long
as the stream exists. Any positive value plays the stream for the corresponding number of seconds. For a recorded
stream, a value of
-1 plays the entire file, and a value of 0 returns the first video frame. Any positive number plays
the stream for the corresponding number of seconds. By default, the value is -1. This parameter is optional.
reset A boolean value, or number, that flushes the playing stream. If reset is false (0), the server maintains a
playlist, and each call to
Stream.play() is appended to the end of the playlist so that the next play does not start
until the previous play finishes. You can use this technique to create a dynamic playlist. If
reset is true (1), any
playing stream stops, and the playlist is reset. By default, the value is
true.
You can also specify a number value of 2 or 3 for the
reset parameter, which is useful when playing recorded stream
files that contain message data. These values are analogous to
false (0) and true (1), respectively: a value of 2
maintains a playlist, and a value of 3 resets the playlist. However, the difference is that specifying either 2 or 3 for
reset returns all messages in the specified recorded stream at once, rather than at the intervals at which the
messages were originally recorded (the default behavior).
remoteConnection A NetConnection object that is used to connect to a remote server. If this parameter is
provided, the requested stream plays from the remote server. This is an optional parameter.
virtualKey A string indicating a key value. Starting with Flash Media Server 2, stream names are not always
unique; you can create multiple streams with the same name, place them in different physical directories, and use
the
VirtualDirectory section and VirtualKeys section of the Vhost.xml file to direct clients to the appropriate
stream. Because the
Stream.length() method is not associated with a client, but connects to a stream on the server,
you may need to specify a virtual key to identify the correct stream. For more information about keys, see
Client.virtualKey. This is an optional parameter.
Returns
A boolean value:
true if the call is accepted by the server; otherwise, false. If the server fails to find the stream, or
if an error occurs, the
Stream.play() method can fail. To get information about the Stream.play() method,
define a
Stream.onStatus() handler.
If the
streamName parameter is false, the stream stops playing. A boolean value of true is returned if the stop
succeeds; otherwise,
false.
Example
The following example shows how streams can be chained between servers:
application.myRemoteConn = new NetConnection();
application.myRemoteConn.onStatus = function(info){
trace("Connection to remote server status " + info.code + "\n");
// Tell all the clients.
for (var i = 0; i < application.clients.length; i++){
application.clients[i].call("onServerStatus", null,
info.code, info.description);
}
};
// Use the NetConnection object to connect to a remote server.
application.myRemoteConn.connect(rtmp://movie.com/movieApp);
// Set up the server stream.
application.myStream = Stream.get("foo");
if (application.myStream){
application.myStream.play("Movie1", 0, -1, true, application.myRemoteConn);
}
The following example shows how to use Stream.play() as a hub to switch between live streams and recorded
streams:
Commenti su questo manuale