
Client-Side Communication ActionScript 101
Video.attachVideo
Availability
• Flash Player 6.
• Flash Communication Server MX (not required).
Usage
myVideoObject.attachVideo(source | null)
Parameters
source A NetStream or Camera object that is playing or capturing video data, respectively. To
drop the connection to the Video object, pass
null for source.
Returns
Nothing.
Description
Method; specifies a video stream (source) to be displayed within the boundaries of the Video
object on the Stage. The video stream is either a NetStream object being displayed by means of
the
NetStream.play command (requires Flash Communication Server), a Camera object, or
null. If source is null, video is no longer played within the Video object.
Example
The following example plays live video locally, without the need for Flash Communication
Server.
myCam = Camera.get();
myVid.attachVideo(myCam); // myVid is a Video object on the Stage
The following example shows how to publish and record a video, and then play it back.
// This script publishes and records video
// The recorded file will be named "allAboutMe.flv"
connection = new NetConnection();
connection.connect("rtmp://localhost/allAboutMe/mySpeech");
publishStream = new NetStream(connection);
publishStream.publish("allAboutMe", "record");
publishStream.attachVideo(Camera.get());
// This script plays the recorded file.
// Note that no publishing stream is required to play a recorded file.
connection = new NetConnection();
connection.connect("rtmp://localhost/allAboutMe/mySpeech");
subscribeStream = new NetStream(connection);
subscribeStream.play("allAboutMe");
myVid.attachVideo(subscribeStream);// myVid is a Video object on the Stage
See also
Camera (object), NetStream.play, NetStream.publish
Kommentare zu diesen Handbüchern