Changing OSX’s default webcam

Have you ever tried to use the webcam feature on a site and hear from a tester using a MacBook that his or her webcam was not being initialized? Below we may have the solution for you:

During testing of a recent project we realized that in OSX the Camera.getCamera() function was not working. Of course, there was no error being displayed in the debug Flash Player, and everything else seem to function as if nothing had gone wrong. The camera just didn’t work.  We decided to check the Camera Settings in the Adobe Flash Player Settings (you can find these settings by right clicking any embedded flash, choosing settings, and then selecting the web-cam icon  tab). To our surprise we found that in OSX the option “DV Video” was selected by default.  What needed to be selected was “USB Video Class Video”.

Most of us are used to using Camera.getCamera() and it magically working.  Well there is a string value that can be passed through getCamera() that allows you to specify witch camera to use. The string value is the index position in the Camera.names array.  So, in order to select the second camera in the array you would use Camera.getCamera(“2”).  All that’s needed now is a loop through the Camera.names array in order to find the index and then passing the index as a string to select the correct camera.

Here’s our solution:

var camera:Camera;
var amnt:int = Camera.names.length;
var index:String;

for(var i:int = 0; i<; i++) {
if(Camera.getCamera(String(i)).name == "USB Video Class Video") {
index = String(i);
break;
}
}
camera = Camera.getCamera(index);

Leave a Reply