Previously featured in our article detailing hardware capabilities of PWA, camera access is one of the more prominent features that we’re seeing more and more of. But to properly integrate this capability into your PWA isn’t an easy task either, which is why in our article today, we’ll guide in through this whole process:
Contents
**getUserMedia()**
— an API of webRTCTo get direct access to a camera and/or a microphone, the Web uses an API called getUserMedia()
which is widely supported in almost all modern browsers. This API, along with RTCPeerConnection
and RTCDataChannel
, are parts of the WebRTC — a framework built into browsers that enables real-time communication.
Basically, what the API (navigator.mediaDevices.getUserMedia(constraints)
) does is it prompts the user for permission to access audio and video input of the phone (e.g., microphone, webcam, camera, etc). Using which permission, the API generates a MediaStream
JavaScript object called local that can be further manipulated.
#progressive web apps #progressive web app