D
D
Denisca Gareev2020-06-17 11:42:20
JavaScript
Denisca Gareev, 2020-06-17 11:42:20

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));

Chrome phone browser.
Phone cameras are working.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dubolom Unicellular, 2020-06-17
@Denisca2828

Maybe it's because of localhost? Sometimes javascript on localhost gets blocked

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question