Camera Object

The Camera object controls access to most video sources attached to a client's computer. The Camera object controls capture settings including frame size, frame rate, and bandwidth. You can also set the Camera to trigger an event when it detects motion (or no motion). Macromedia Flash Communication Server is required to record or transmit the video source to other Flash clients; however, the Camera object can be accessed locally without the server.

The camera is enabled using the Camera.get() method. To enable Code Hints and Code Completion in Macromedia Flash MX ActionScript Editor, use the suffix _cam in the name of the Camera variable.

Camera Methods

Camera.get([index])

Captures the camera feed and assigns it to an embedded video object or a NetStream. You can quickly access the camera feed using attachVideo.

[index] The integer number identifying an individual camera in a multicamera environment. The number is determined by the Camera.names property. To select the default camera, omit this parameter.

Camera.setKeyFrameInterval(keyframeInterval)

Overrides the video compression algorithm by setting a different keyframe rate. This will allow you to adjust the quality and bandwidth required by the video feed. Keyframes are uncompressed frames embedded within the video. The video compressor interpolates the visual difference between keyframes to re-create the frames between the keyframes. The default value is 15 frames.

keyframeInterval The number of full video frames to capture per second. The lower the value, the higher the quality of the video and the larger the file size.

Camera.setLoopback(compressLocalStream)

Views the camera feed as it will be sent to Flash Communication Server. Enabling this loop back will engage the video compressor.

compressLocalStream A Boolean value. When set to true, it displays the compressed version of the video locally.

Camera.setMode(width, height, fps [,favorSize])

Defines the camera capture driver settings. These settings will increase/decrease bandwidth and quality.

width The capture width; default value is 160.
height The capture height; default value is 120.
fps The capture frames per second; default value is 15.
favorSize A Boolean value. When set to true, it specifies to the camera how to handle the capture settings, if the camera doesn't support the sizes natively.

Camera.setMotionLevel(sensitivity [, timeout])

Sets the motion sensitivity, or how much motion would be required to trigger the Camera.onActivity event.

sensitivity The motion sensitivity value from 0 to 100, 100 being highest sensitivity; default value is 50.
timeout The length of time in milliseconds of no motion before setting the Camera.onActivity event to false; default value is 2000 (2 sec).

Camera.setQuality(bandwidth, frameQuality)

Sets the maximum bandwidth and frame quality the camera source can consume when publishing to Flash Communication Server.

bandwidth The bandwidth limit the camera can consume. A setting of 0 supplies the maximum bandwidth available; default value is 16384.
frameQuality The amount of video compression applied to each frame. The default value is 0 for a variable compression rate as per the bandwidth available. The quality range is from 1 (most compression and lowest quality) to 100 (least compression and highest quality).

Camera Properties

Camera.activityLevel returns the amount of motion being received by the camera.

Camera.bandwidth returns the bandwidth limit allocated by the setQuality method.

Camera.currentFPS returns the rate, in frames per second, at which the camera is currently capturing.

Camera.height returns the current frame height being captured by the camera. To set the height, use Camera.setMode.

Camera.index returns the index of the camera being used.

Camera.keyFrameInterval returns which frames are sent uncompressed. This can be set using Camera.setKeyFrameInterval.

Camera.loopBack returns a Boolean value. A value of true is returned if the video output is filtered through the internal video compressor.

Camera.motionLevel returns the motion sensitivity value of the camera. This is set using Camera.setMotionLevel.

Camera.motionTimeOut returns the timeout value, in milliseconds, when the camera will trigger the Camera.onActivity event with a false value. This indicates there is no motion in front of the camera.

Camera.muted returns a Boolean value. A value of false indicates the client has not allowed camera access when prompted by the Flash player Privacy Settings panel.

Camera.name returns the manufacturer's name of the current camera.

Camera.names returns an array of strings containing the names of all camera sources available to the Flash player. This will not invoke the Privacy Settings panel.

Camera.Quality returns the amount of compression being applied to the outgoing camera feed. This can be set using Camera.setQuality.

Camera.width returns the current frame width being captured by the camera. To set the width, use Camera.setMode.

Camera Events

Camera.onActivity is invoked when motion occurs or stops occurring in the camera's range of view. This event can be controlled using Camera.setMotion.

Camera.onStatus is invoked when the status of the camera changes. The status will change only if the user denies camera access in the Flash player Privacy panel. This event will receive a Camera Information object detailed in Appendix C,"Information Objects (Server and Client) Quick Reference."



    Part I: 10 Quick Steps for Getting Started