Error activating microphone in google Chrome
Asked Answered
K

1

11

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);
            })
Kennie answered 5/11, 2019 at 17:33 Comment(2)
Hello! For us to help you better, I think the version of your Google Chrome would be useful to know. You can also post the value of navigator.userAgent instead. Otherwise, I am pretty sure navigator.mediaDevices.getUserMedia is a function offered by Chrome (and Firefox, and some other user agents as per one or the other standardized Web API).Paestum
Version 76.0.3809.132 (64 bit)Kennie
V
23

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

Vital answered 5/11, 2019 at 17:38 Comment(2)
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-contentPaestum
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!Vital

© 2022 - 2024 — McMap. All rights reserved.