14.7. Subscribing to Audio/Video Content
Problem
You want to subscribe a Flash movie to audio and/or video content from a FlashCom server.
Solution
Create a net stream that uses an existing net connection to the
FlashCom server and invoke the NetStream.play( )
method.
Discussion
FlashCom audio and video are transferred between the client and
server using net streams. When a Flash movie accesses a net stream of
a FlashCom application, it is said to be
subscribed to that net stream.
The NetStream class, from which you can create
net stream objects, facilitates the sending and receiving of audio
and video. You should use a net stream object to subscribe to any
audio or video content from a FlashCom server. The same code is used
to receive the stream whether that content has been previously
recorded or whether it is live. When you create a net stream object,
you must specify the net connection object (see Recipe 14.2) over which the stream should be sent.
For example:
// Create theNetConnectionobject. myConnection = new NetConnection( ); // Call theNetConnection.connect( )method to connect to an application. myConnection.connect("rtmp:/myApplication/"); // Create a net stream that uses the net connectionmyConnection. subscribe_ns = new NetStream(myConnection);
Once you have created a net stream object, you can use the
NetStream.play( ) method to subscribe to any
available audio and/or video content on the server. The
play( ) method requires you to specify the name of the stream as it ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access