Each phone has a built-in Camera app which can be used to take a photo or record a video. However, they are triggered via app shortcut. What if you want users to access camera feature while visiting your website?
This is simpler than you think of.
[html]
//front-camera
<input type="file" accept="image/*" capture="user" />
//rear-camera
<input type="file" accept="image/*" capture="environment" />
[/html]
This field is just a normal File field so you don’t need to handle your form differently. Remember that this field only works with iOS6+ or Android 3.0+, which is not an issue anymore. Devices produced in recent years run on a higher OS version.
In case you want to record video or audio, below are 2 neccessary HTML5 fields.
[html]
<input type="file" accept="video/*;capture=camcorder">
<input type="file" accept="audio/*;capture=microphone">
[/html]
In case you want to control the camera better, WebCodeCamJS can be used.
It is a JavaScript library which handles camera input. WebCodeCamJS is very simple usage (but more complex than basic HTML5), has some options for optimal result, and is optimized for most modern browsers.