How to get information about the microphone equipment (built-in)?

Is it possible to read the equipment information (at least the name) of the microphone (built-in) when a user records an audio file on my website?

Is this possible using JavaScript or is there another way to solve this problem? I searched on the Internet, but could find scripts to write using JavaScript.

+4
source share
2 answers

Newer version : Available in Firefox, MS Edge, and Chrome 45 with an experimental flag.

Using the standard navigator.mediaDevices.enumerateDevices() , you can get a list of available sources. Each source has a kind property, as well as a label .

 var stream; navigator.mediaDevices.getUserMedia({ audio:true }) .then(s => (stream = s), e => console.log(e.message)) .then(() => navigator.mediaDevices.enumerateDevices()) .then(devices => { stream && stream.stop(); console.log(devices.length + " devices."); devices.forEach(d => console.log(d.kind + ": " + d.label)); }) .catch(e => console.log(e)); var console = { log: msg => div.innerHTML += msg + "<br>" }; 
 <div id="div"></div> 

Documentation and Related

The last demo works in regular Chrome thanks to adapter.js polyfill.

+8
source

Deprecated API

This answer uses a non-standard API with limited browser support. It works in current Chrome at the time of writing, but will not be accepted in future versions of other browsers and may go away in Chrome. For a solution with wider support see: fooobar.com/questions/1600704 / ...


Using MediaStreamTrack.getSources() , you can get a list of available sources. Each source has a kind property, as well as a label .

 MediaStreamTrack.getSources(function(sourceInfos) { for (var i = 0; i != sourceInfos.length; ++i) { var thisSource = sourceInfos[i]; console.log('stream type: '+thisSource.kind+', label: '+thisSource.label); // example: stream type: audio, label: internal microphone } }); 

Documentation and Related

+1
source

All Articles