I'm having trouble with Camera.getCamera() in Flash AS3. If there are multiple camera drivers, it does not necessarily pick the correct one. If the default is the correct, the program works fine; however, if another driver is selected as the default then LED on the webcam does not come on and no video is captured. I can cycle through the available cams and select an arbitrary one. I don't, however, know how to determine if the selected camera is correct. It is not returning null. I considered using camera.currentFPS, but it's not clear when this gets updated. I'm really struggling to determine dynamically which camera will do the trick!
Check out this blog post, it could be of use for what you're trying to do.
I remeber I used this class a while ago, because there were problems detecting the right webcam in Macs in an app I was working on. Never experienced this problem for Windows or Linux, though.
I was on a rather tight deadline then, so I didn't really investigate much about the subject. I remember this code had some problems with some built-in cameras in laptops running Windows. I ended up just checking flash.system.Capabilities.os
to detect whether the client was a Mac or not. For Macs, I used the code in this class, as is. For everything else, I just detected the camera the "regular way" (i.e., getting the default camera). It worked fine in all our tests, and since time was short, that settled it.
To be honest, though, I'm not sure if it covers some corner cases. You might want to check that, but hopefully, this will give you at least some pointers -- if not a solution.
Hope this helps.
The thing you want is probably activityLevel http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/media/Camera.html#activityLevel But if you're just having issues selecting the "correct" camera in OSX I suggest you use a drop down and let the user select. Use the Camera.names to fill the selection drop-down and use the selected index to do the actual selection. One major gotcha is to make sure you use a string to select the camera, it is the opposite of Microphone selection wherein a number is used.
//camera uses string
var camera:Camera = Camera.getCamera("0");
//microphone uses number
var mic:Microphone = Microphone.getMicrophone(0);
//method to handle the selection of a new camera
private function changeCamera(evt:ListEvent):void {
camera = Camera.getCamera(evt.currentTarget.selectedIndex.toString());
}
I have seen differences with windows and osx myself but I don't recall the exact problem.