⚠️ Warning: this is an old article and may include information that’s out of date. ⚠️

I fired up the newly released Android 3.0 SDK to run some tests and found they’ve implemented part of the long-awaited Device API (aka the Media Capture API). From your browser you can now upload pictures and videos from the camera as well as sounds from the microphone. The returned data should be available to manipulate via the File API (although I haven’t yet tested this).

Video

I made a short video demo with some explanation:

Code

Here’s the code so you can play around with it for yourself!

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
<form enctype="multipart/form-data" method="post">
  <h2>Regular file upload</h2>
  <input type="file"></input>

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

  <h2>capture=camcorder</h2>
  <input type="file" accept="video/*;capture=camcorder"></input>

  <h2>capture=microphone</h2>
  <input type="file" accept="audio/*;capture=microphone"></input>
</form>