O'Reilly logo

Actionscript Cookbook by Joey Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 the NetConnection object.
myConnection = new NetConnection(  );

// Call the NetConnection.connect(  ) method to connect to an application.
myConnection.connect("rtmp:/myApplication/");

// Create a net stream that uses the net connection myConnection.
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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required