Can You Launch the Native Camera App from an HTML 5 Web App

Can you launch the native Camera App from an Html 5 Web App?

Android 3.0 Honeycomb added Device API support.
Google I/O 2011 presentation shows an example on slide 30:

<input type="file" accept="image/*;capture=camera">

It also points to a test site that not surprisingly does not do much on my Froyo phone.

Anybody with a tablet tried it and can tell us what it does and does not do?

4.0 Icecream Sandwich was announced. Code drop may not happen for several months or longer and actual devices may show in the market around Christmas. As to Icecream on current generation of Froyo / Gingerbread phones, official ODM/carrier 4.0 releases will never happen? I'd love to be proved wrong on this. Any word from custom ROMs community?

Web application - Capture a photo?

The getUserMedia API doesn't require any external libraries and allows Javascript access to the Webcam for photos or videos. The downside is that this is only supported on Chrome, Firefox and Edge currently. See CanIUse

The only other option is to use an external plug-in like Flash or Silverlight to access the webcam.

Using form input to access camera and immediately upload photos using web app

It's really easy to do this, simply send the file via an XHR request inside of the file input's onchange handler.

<input id="myFileInput" type="file" accept="image/*;capture=camera">

var myInput = document.getElementById('myFileInput');

function sendPic() {
var file = myInput.files[0];

// Send file here either by adding it to a `FormData` object
// and sending that via XHR, or by simply passing the file into
// the `send` method of an XHR instance.
}

myInput.addEventListener('change', sendPic, false);


Related Topics



Leave a reply



Submit