I'm trying to access the camera on iOS through implementing the getUserMedia API in my React App. My code works fine when I navigate run it in StackBlitz on iOS Safari. However when I navigate to mylocalIP:3000 on iOS Safari, the component doesn't prompt for access to the webcam. See my component here or below:
const Video: React.FC = () => {
useEffect(() => {
start()
})
const constraints = {
audio: false,
video: true
};
async function start() {
const stream = await navigator.mediaDevices.getUserMedia(constraints)
const video = document.getElementById('video') as HTMLVideoElement;
video.setAttribute("playsinline", "true");
video.setAttribute("controls", "true");
video.srcObject = stream;
}
return (
<video id='video' autoPlay playsInline></video>
)
}
export default Video
Yes, followed all steps.
Nothing relevant in the User Guide
Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Binaries:
Node: 10.14.1 - ~/.nvm/versions/node/v10.14.1/bin/node
Yarn: Not Found
npm: 6.10.3 - ~/.nvm/versions/node/v10.14.1/bin/npm
Browsers:
Chrome: 79.0.3945.88
Firefox: Not Found
Safari: 13.0.4
npmPackages:
react: ^16.10.2 => 16.10.2
react-dom: ^16.10.2 => 16.10.2
react-scripts: 3.2.0 => 3.2.0
npmGlobalPackages:
create-react-app: 3.3.0
(Write your steps here:)
npm startyour-ip:3000 on iOS SafariThe phone will prompt to share the webcam with the site.
Screen displays an empty video icon.
StackBlitz Demo
Copy that code into CRA and navigate to the hosted site.
Duplicate of #8234?
@heyimalex #8234 is clearly a duplicate of this one, not the other way round....
Sorry! I just saw the other one first, figured you were co-workers that just miscommunicated.