- From: Rich Tibbett <richt@opera.com>
- Date: Mon, 26 Mar 2012 11:38:01 +0200
- To: Harald Alvestrand <harald@alvestrand.no>
- CC: public-media-capture@w3.org
Harald Alvestrand wrote:
> On 03/24/2012 05:50 PM, Bryan Sullivan wrote:
>> Harald, FYI
>>
>> To get your example to work, I had to replace:
>>
>> video.src = webkitURL.createObjectURL(s);
>>
>> With
>>
>> video.src = webkitURL.createObjectURL(stream);
>
> Sorry 'bout that - was cleaning up the script after having pasted it
> into the mail, and did not run it before hitting "send".
>
> BTW, I do agree that the redirection via a video tag before getting to
> the canvas is crufty.
>
This is a reasonable methodology if you're doing e.g. real-time image
processing. It's an advanced usage. Just for completeness (and FYI) it
should be noted that an easier way also exists if the use case is simply
to obtain a one-off image from the user's camera:
<input type=file accept="image/*;capture=camera"/>
<img src=""/>
<script>
var input = document.getElementsByTagName('input')[0],
image = document.getElementsByTagName('img')[0];
input.onchange = function() {
var fileList = this.files;
if(fileList.length > 0)
image.src = window.URL.createObjectURL(fileList[0]);
}
</script>
This implementation of [1] opens the native camera app, allows the user
to take a picture - applying any camera settings as they wish - and the
resulting image is returned as an async callback in-page.
As of today, this is already supported in the Android browser [2] and
Chrome for Android, I believe.
- Rich
[1] http://www.w3.org/TR/html-media-capture/
[2]
http://davidbcalhoun.com/2011/android-3-0-honeycomb-is-first-to-implement-the-device-api
Received on Monday, 26 March 2012 09:38:30 UTC