Displaying a webcam’s video in a Flex VideoDisplay control


The following example shows you how you can display a user’s webcam feed in a VideoDisplay control using the static Camera.getCamera() method and VideoDisplay class’s attachCamera() method.

Full code after the jump.

<?xml version=”1.0″ encoding=”utf-8″?>
<!– http://blog.flexexamples.com/2008/01/22/displaying-a-webcams-video-in-a-flex-videodisplay-control/ –>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221;
layout=”vertical”
verticalAlign=”middle”
backgroundColor=”white”>

<mx:Script>
<![CDATA[
import mx.controls.Alert;

private function videoDisplay_creationComplete():void {
var camera:Camera = Camera.getCamera();
if (camera) {
videoDisplay.attachCamera(camera);
} else {
Alert.show(“You don’t seem to have a camera.”);
}
}
]]>
</mx:Script>

<mx:VideoDisplay id=”videoDisplay”
creationComplete=”videoDisplay_creationComplete();”
width=”160″
height=”120″ />

<mx:Button id=”button”
label=”Reload Camera”
click=”videoDisplay_creationComplete();” />

</mx:Application>

~ by mjcprasad2000 on April 11, 2009.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: