-
Auto Webcam Detection
4.19.11 **UPDATE** Now on GitHub. Also, much better than before.
This project 'CameraDetection' does one thing; Find the first working Camera object in AS3.
This class looks at all of the available Cameras in the Camera.names list and tests them. Using a combination of fps and activity, each Camera is looked at until one is deemed usable.
It's pretty simple to use:
PHP Code:
import ktu.media.CameraDetection;
import ktu.events.CameraDetectionEvent;
var cd:CameraDetection = new CameraDetection();
cd.addEventListener (CameraDetectionEvent.RESOLVE, onResolve);
cd.begin();
function onResolve (e:CameraEvent):void {
switch (e.code) {
case CameraDetectionEvent.SUCCESS:
var myCamera:Camera = e.camera;
break;
case CameraDetectionEvent.NO_SUCCESS:
// none of the camera's worked properly
break;
case CameraDetectionEvent.NO_PERMISSIONS:
// the user denied permission
break;
case CameraDetectionEvent.NO_CAMERAS:
// no camera's were found
break;
}
}
-
I've made an update to this class. It now has better detection, and faster detection on Mac laptops.
-
I have made another update to this class.
Added better support for determining permissions.
Updated some logic.
Cleaned up code.
No magic values.
This is a great class folks
-
2012.10.06 update
UPDATED 2012.10.06
A lot has changed:
MediaPermissions object makes asking for permission easy as, well, adding an eventlistener to an object...
CameraChecker was a pleasant abstraction that simplified the CameraDetection code
check out the blog post
go to github to get it
-
Thumbs up for updating 2 years old project!