title: How to detect that system connected with microphone using JavaScript
body: <p>I'm using <code>getUserMedia()</code> for audio recording and it works correctly but have an issue with it.</p>
  
  <p>I want to display a message before starting recording that any microphone is connected with system or not.</p>
  
  <p>For this I have used following code and run this into chrome but it was not working correctly.</p>
  
  <pre><code>if(navigator.getUserMedia || navigator.webkitGetUserMedia)
  {
     alert("Microphone is connected with your system");
  } else {
     alert("Microphone is not connected with your system");
  }
  </code></pre>
  
  <p>when microphone is not connected then also above code giving message "Microphone is connected with your system".</p>
  
  <p>so please suggest me a better way to detect microphone using JavaScript in any browser.</p>