Error activating microphone in google Chrome

12,055

Grabbing navigator.mediaDevices as of Chrome 74 requires a secure context.

https://developer.mozilla.org/en-US/docs/Web/API/Navigator/mediaDevices

This means that non https:// requests will return an undefined object.

For more information on this change: https://w3c.github.io/mediacapture-main/#local-content

Share:
12,055
pzsette
Author by

pzsette

Updated on June 15, 2022

Comments

  • pzsette
    pzsette almost 2 years

    Im trying to enable microphone to allow user record audio, but I get this error:

    Uncaught TypeError: Cannot read property 'getUserMedia' of undefined at activateMicrophone

    navigator.mediaDevices.getUserMedia({audio: true, video:false})
                .then(stream => {
                    handlerFunction(stream, $audioSelect.siblings(".recordedAudio"));
                    $(".record").prop("disabled", false);
                })
    
  • Armen Michaeli
    Armen Michaeli over 4 years
    I believe you linked wrong resource -- MDN doesn't say anything about how access to mediaDevices from scripts from insecure origins is handled. What you want to link to is w3c.github.io/mediacapture-main/#local-content
  • Bitz
    Bitz over 4 years
    The browser compatibility section covers the change with respect to secure contexts and Chrome versioning. Your link does actually cover the change explicitly but doesn't cover the browsers for which the changes are effective. I will include both resources as an edit. Thanks!