package classes.matuto.midia
{
	import flash.media.Camera;
	import flash.system.Capabilities;

	public class WebCam
	{
		private static const MAC_CAMERA	:String = "USB Video Class Video";
		
		public static function getCamera() :Camera
		{
			var AdobeVersion	:String = Capabilities.manufacturer;
			var idCam			:*;
			var realCam			:* = null;
			var cam				:Camera;
			
			if (AdobeVersion == "Adobe Macintosh") {
				for (idCam in Camera.names) {
					if (Camera.names[idCam] == MAC_CAMERA) {
						realCam = idCam.toString();
						break;
					}
				}
				cam = Camera.getCamera(realCam);
			} else {
				cam = Camera.getCamera();
			}
			
			return cam;
		}
		
		public static function exist() :Boolean
		{
			var _exist :Boolean = Boolean(Camera.names.length);
			
			return _exist;
		}
		
	}
}