I am using the below line of code in order to invoke camera from my web application.
<input type="file" id="capture" accept="image/*; capture=camera" style="visibility:hidden;">
Using this, I am able to get the pop up with options of "Choose existing photo" and "Take Picture", when the application is opened in iOS6. But I want to open up camera capture directly rather then getting this pop up and then select "Take Picture" option.
Thanks in advance.
The capture attribute is supported on the file input type. The capture attribute takes as its value a string that specifies which camera to use for capture of image or video data, if the accept attribute indicates that the input should be of one of those types. The user-facing camera and/or microphone should be used.
The value property returns the path or the name of the file selected with the <input type="file"> element. This property returns the name of the selected file with a fake path in IE, Google Chrome, and Opera, and the name of the selected file in Firefox and Safari.
<input type="file" name="file" accept="image/*" capture="camera" />
Works in Chrome on Android (at least).
I'm afraid this is not possible as per the specification for security/privacy reasons:
The user agent SHOULD NOT enable any device for media capture, such as a microphone or camera, until a user interaction giving implicit consent is completed.
http://www.w3.org/TR/capture-api/#security
An alternative is to use getUserMedia. This still shows a dialog requesting user permission but in some browsers the user can choose to hide it after granting access to a domain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With