'AudioConstraints don't work with navigator.mediaDevices.getUserMedia

No matter what I set for the audio constraints, it doesn't seem to affect the audio stream's settings. I have tried different microphones and browsers. I'm trying to get the highest quality stream. I would like a 192k bitrate but I'm not quite sure how sample rate and sample size translate to bitrate.

var textarea = document.createElement('pre');
document.body.insertBefore(textarea,document.body.firstChild)

var constraints =  {
  audio: { 
            sampleSize: 24 //no number works
            sampleRate: 41000 //nothing works unless I use a bad number like 8, then it drops to 24000
         }
}
navigator.mediaDevices.getUserMedia(constraints).then(function success(stream) {
    stream.getTracks().forEach(function(track) {
    textarea.innerHTML = textarea.innerHTML+track.kind+":"+JSON.stringify(track.getSettings(),null, 2);
    })
}).catch(function(err) {
   textarea.innerHTML = err.message;
});

codepen example: https://codepen.io/trackedsupport/pen/BamNvXZ



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source