PDA

View Full Version : Streaming Webcam videos in Flex Application


g_sri1987
06-26-2009, 11:42 AM
I am a newbie to Adobe Flex and AIR.
I have a number of webcams connected to my system. Now I want to create a desktop application which can stream the videos of all the webcams on to the AIR Application. The applicatio will look like a CCTV Surveillance system where you can monitor all the webcams on one screen, each in a different Panel.
Earlier I was trying to implement it using Java and JMF but couldn't get much success. There is bug in JMF that it can't detect more than one webcams concurrently. Experts suggested me to move on to Adobe Flex.
In flex I am facing a few problems:
1. The code snippet which I got to detect a webcam and stream its video is not exactly streaming from Webcam, rather it is streaming my Desktop. Can any body suggest me how to stream the Video of my webcam rather than my desktop. The code is mentioned below:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initCamera()">
<mx:Script>
<![CDATA[
import flash.media.Camera;
import flash.media.Video;
import mx.core.UIComponent;
public var videoHolder:UIComponent;
public var cam:Camera;

public var video:Video;
public function initCamera():void {
videoHolder = new UIComponent();
cam = Camera.getCamera();

video = new Video(320,240);
video.attachCamera(cam);
videoHolder.addChild(video);
cnvWebcam.addChild(videoHolder);
}
]]>
</mx:Script>
<mx:Canvas id="cnvWebcam" >
</mx:Canvas>
</mx:WindowedApplication>

2. Once this is done for a single webcam, I would like to implement it for Multiple webcams. For that I need to retrieve a list of all the webcams connected to my system. If any body can help me on this too.

thanks
gaurav

g_sri1987
06-26-2009, 07:32 PM
i got the solution....
i just had to use parameter in getCamera option :)