Face-Detection-JavaScript icon indicating copy to clipboard operation
Face-Detection-JavaScript copied to clipboard

TypeError: navigator.getUserMedia is not a function

Open ghost opened this issue 6 years ago • 14 comments

error in Firefox

TypeError: navigator.getUserMedia is not a function

Screenshot (280)

ghost avatar Oct 16 '19 08:10 ghost

Try using navigator.mediaDevices.getUserMedia()

On Wed, Oct 16, 2019 at 3:27 AM PratikBalar [email protected] wrote:

error in Firefox

TypeError: navigator.getUserMedia is not a function

[image: Screenshot (280)] https://user-images.githubusercontent.com/41847153/66901741-e9933500-f01c-11e9-9ace-681293a2dd56.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/WebDevSimplified/Face-Detection-JavaScript/issues/9?email_source=notifications&email_token=AJPAR257VKZ5Q44ECNAE54LQO3GAFA5CNFSM4JBIAJ3KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HSC2ICA, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJPAR25OLUFLUOMFAJWNAATQO3GAFANCNFSM4JBIAJ3A .

WebDevSimplified avatar Oct 16 '19 13:10 WebDevSimplified

.... is not a function Screenshot (281)

ghost avatar Oct 16 '19 13:10 ghost

What version of firefox are you using? Maybe this API is not available in your version.

On Wed, Oct 16, 2019 at 8:38 AM PratikBalar [email protected] wrote:

.... is not a function [image: Screenshot (281)] https://user-images.githubusercontent.com/41847153/66924472-53750400-f048-11e9-9003-e768543e55d7.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/WebDevSimplified/Face-Detection-JavaScript/issues/9?email_source=notifications&email_token=AJPAR23ODDO3HR7RLFJ4ZQLQO4KNPA5CNFSM4JBIAJ3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBMQM3A#issuecomment-542705260, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJPAR264FARKBCRBAA2SCRLQO4KNPANCNFSM4JBIAJ3A .

WebDevSimplified avatar Oct 16 '19 13:10 WebDevSimplified

i.m using Firefox 69 .but i also tried it in chrome (Chrome 77 on Windows 10) and ..... Screenshot (283)

ghost avatar Oct 16 '19 14:10 ghost

getUserMedia() is a promises so you have to use .then()

navigator.mediaDevices.getUserMedia().then((stream)=> {})

souravgolui avatar Oct 17 '19 10:10 souravgolui

You need to make sure you pass parameters to the getUserMedia function like I did in the code. That is why you are getting your first error.

WebDevSimplified avatar Oct 17 '19 11:10 WebDevSimplified

navigator.mediaDevices.getUserMedia({video: {}}) .then((stream)=> {video.srcObject = stream;}, (err)=> console.error(err));

souravgolui avatar Oct 19 '19 16:10 souravgolui

navigator.mediaDevices.getUserMedia({video: {}}) .then((stream)=> {video.srcObject = stream;}, (err)=> console.error(err));

Had the same error in FireFox, and this fix worked for me!

devdanielsun avatar Nov 21 '19 00:11 devdanielsun

working in chrome but still not working in firefox (v69.0.1). image

ghost avatar Nov 22 '19 17:11 ghost

You must have on secure context

The getUserMedia() method is only available in secure contexts. A secure context is one the browser is reasonably confident contains a document which was loaded securely, using HTTPS/TLS, and has limited exposure to insecure contexts. If a document isn't loaded in a secure context, the navigator.mediaDevices property is undefined, making access to getUserMedia() impossible.

Attempting to access getUserMedia() in this situation will result in a TypeError.

https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia

febriwidhawanto90 avatar Dec 08 '19 19:12 febriwidhawanto90

When I run the project on localhost it runs fine. But when I host it on my server instance then try to run it, then it gives this error. Any idea why its behaving like that?

tulaibpirzada avatar Jan 28 '20 19:01 tulaibpirzada

Chrome is requiring secure origins (HTTPS) for getUserMedia.

Starting with Chrome 47, getUserMedia() requests are only allowed from secure origins: HTTPS or localhost.

https://developers.google.com/web/updates/2015/10/chrome-47-webrtc?hl=en

sapabapdev avatar Apr 24 '20 23:04 sapabapdev

When I run the project on localhost it runs fine. But when I host it on my server instance then try to run it, then it gives this error. Any idea why its behaving like that?

are you on HTTPS? I mean the domain on your server? it should be on https for it to work.

FotieMConstant avatar Jun 02 '20 23:06 FotieMConstant

When I run the project on localhost it runs fine. But when I host it on my server instance then try to run it, then it gives this error. Any idea why its behaving like that?

are you on HTTPS? I mean the domain on your server? it should be on https for it to work.

My server is https but still not working and working fine on localhost

greatforu avatar Jul 16 '20 07:07 greatforu