Babu
Babu

Reputation: 442

In flash as3 webcam how to get newly connected webcam name at run-time?

I have a flash as3 based webcam video recorder that publishes the webcam video stream and to do this i am using the following codes :

var camera:Camera = Camera.getCamera(0);
var arr:Array = Camera.names;
if(camera != null)
{
    videoWidth = topBorderContainer.width;
    videoHeight = topBorderContainer.height;
    camera.setMode(videoWidth, videoHeight, 30, false);
    camera.setQuality(0, 100);
    if (camera)
    {
        videoDisplay.videoObject.attachCamera(camera);
    }
}

But problem is that if i am connecting a new document camera at run time and running my webcam tool then Camera.names returning the previously connected document camera name instead of returning the new document camera name.

And to get new document webcam name i have to restart my application again.

But i have no knowledge how to get newly connected document camera name at run time so if anybody know how to get the newly connected document camera name at run time please help me to solve.

Upvotes: 0

Views: 259

Answers (1)

Organis
Organis

Reputation: 7316

It is very likely that you will not be able to pull the trick:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Camera.html#getCamera()

"Scanning the hardware for cameras takes time. When the runtime finds at least one camera, the hardware is not scanned again for the lifetime of the player instance. However, if the runtime doesn't find any cameras, it will scan each time getCamera is called. This is helpful if the camera is present but is disabled; if your SWF file provides a Try Again button that calls getCamera, Flash Player can find the camera without the user having to restart the SWF file."

It is possible that Flash Player treats Workers (http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Worker.html) as separate Flash Player instances and thus a new Worker would be able to access the renewed list of Cameras. You might want to try it.

Upvotes: 1

Related Questions