0 Replies Latest reply on Oct 8, 2009 4:25 AM by Boy Carper

    Detect if user has no camera

    Boy Carper

      Hey there,

       

      I'm trying to detect wether the user has a camera or not installed. In the examples I found you do this by checking if _camera = Camera.getCamera(); results in null. But when I test this on my Mac Mini (without camera) it always returns a camera object;

       

      Here a code snippet:

       

       

      private function setupCamera():void
                {
                     _isMac = Boolean(Capabilities.os.substr(0,3).toLocaleLowerCase() == "mac");
                     if(_isMac)
                     {
                          var total:int = Camera.names.length;
                          var i:int;
                          for(i=0;i<total;i++)
                          {
                               Console.debug("Camera: "+Camera.getCamera(i.toString()).name);
                               switch(Camera.getCamera(i.toString()).name) 
                               {
                                    case "USB Video Class Video":
                                    _camera = Camera.getCamera(i.toString());
                                    _camera = _camera?_camera:Camera.getCamera();
                                    break;
                                    default:
                                    _camera = Camera.getCamera();
                                    break
                               }
                          }
                     } else {
                          _camera = Camera.getCamera();
                     }
                  if (_camera) {
                       _camera.setMotionLevel(_motionLevel);
                       _camera.setMode(_width,_height,_fps);
                      _camera.addEventListener(StatusEvent.STATUS, statusHandler);
                      _isSetup = true;
                  } else {
                       _isSetup = false;
                       dispatchEvent(new Event(NO_CAMERA));
                      Console.debug("No Camera");
                  }
      
      

       

       

      Anyone any ideas?