Answer the question
In order to leave comments, you need to log in
Why doesn't the phone camera work on js?
Hello.
Today I wanted to "play" with the camera, write a site layout, connect js and so that when the user enters he would allow the use of the camera and see his face or his legs)
I found on the Internet how to make a local http server on node.js copied the code, changed it a bit, launched ... Tried on a laptop, everything works. I went to the site from the phone but for some reason it does not ask or show anything. Here is part of the code:
navigator.mediaDevices.getUserMedia({video: true}) .then((stream)=> {
var video = document.getElementById("video-elem");
video.srcObject = stream;
video.play();
alert("OK");
}, (err)=> alert(err));
Answer the question
In order to leave comments, you need to log in
Maybe it's because of localhost? Sometimes javascript on localhost gets blocked
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question