
118
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.1
Server-Side ActionScript Language Reference
Last updated 7/2/2013
Availability
Flash Media Server 4
NetStream class
There are two main use cases for the NetStream class: publishing a stream to a remote Adobe Media Server
Professional and publishing a stream to an RTMFP group.
A NetStream object is a channel inside a NetConnection object. Use the NetStream class to publish streams one-way
through a NetConnection object. Unlike a client-side NetStream object, a server-side NetStream object can only
publish streams; it cannot subscribe to a publishing stream or play a recorded stream.
Publish a stream to a remote server
Note: This use case is available in Adobe Media Server Professional.
Use the NetStream class to scale live broadcasting applications to support more clients. Adobe Media Server
Professional can support only a certain number of subscribing clients. To increase that number, you can use the
NetStream class to move traffic to remote servers while still maintaining only one client-to-server connection.
Note: To copy a stream to a remote server over RTMFP, use the following steps and pass an RTMFP protocol to the
NetConnection.connect() method.
The following steps describe the workflow for publishing a stream to a remote Adobe Media Server Professional:
1 To create a NetConnection, call the NetConnection constructor:
var nc = net NetConnection();
2 To connect to an application on a remote Adobe Media Server Professional, call the connect() method:
nc.connect("rtmp://servername/appname/appinstancename");
Note: You cannot use RTMPT, RTMPE, or RTMPTE when connecting to a remote server.
3 To create a stream over the NetConnection, call the NetStream constructor and pass the NetConnection:
var ns = new NetStream(nc);
4 To publish a stream to a remote server, call publish() and pass a name for the stream.
ns.publish("mystream");
5 To subscribe to this stream, clients connect to the same application on the remote server. To play the stream, call
the
play() method and pass the stream name. The following is client-side code:
mynetconnection.connect("rtmp://servername/appname/appinstancename");
// Check for a "NetConnection.Connect.Success" message, then call play().
mynetstream.play("mystream");
Publish a stream to an RTMFP group
Note: This use case is available in Flash Media Server 4.
The following steps describe the workflow for publishing a stream to an RTMFP group:
1 To create a NetConnection, call the NetConnection constructor:
var nc = net NetConnection();
Comentarios a estos manuales