title: getUserMedia - how to detect if the device actually has a camera
body: <p>I'm playing with the html5/javascript getUserMedia api to write a js app that will use the device's camera if available. I'm using Modernizr to detect the capability (of the browser) like this:</p>
  
  <pre><code>if (Modernizr.getusermedia) {
  </code></pre>
  
  <p>And within the true block:</p>
  
  <pre><code>navigator.getUserMedia(
      {   // we would like to use video but not audio
          // This object is browser API specific! - some implementations require boolean properties, others require strings!
          video: true, 
          audio: false
      },
      function(videoStream) {
          // 'success' callback - user has given permission to use the camera
          // my code to use the camera here ... 
      },
      function() {
          // 'no permission' call back
          console.log("user did not give access to the camera");
      }               
  );
  </code></pre>
  
  <p>This works fine. But what I've found is that the Modernizer.getUserMedia call returns true based on the browser supporting the api, and not whether the device actually has a camera or not.</p>
  
  <p>IE. on my MacBook with its iSight camera and a current version of Chrome, Modernizr.getUserMedia returns true, then navigator.getUserMedia(...) prompts for permission to use the camera. Excellent</p>
  
  <p>However, on another machine without a camera but with a current version of Chrome, Modernizr.getUserMedia returns true, which means that navigator.getUserMedia(...) prompts for permission to use the camera which the device doesn't have. Not so excellent!</p>
  
  <p>Does anyone know if its possible to detect the existance of a camera? Ideally I don't want to prompt the user for permission to access the camera if they dont have one!</p>
  
  <p>Cheers</p>
  
  <p>Nathan</p>