W3C home > Mailing lists > Public > public-device-apis@w3.org > December 2009

Re: Comparing capture* API vs <input type="file" accept="...">

From: Arve Bersvendsen <arveb@opera.com>
Date: Thu, 03 Dec 2009 11:00:26 +0100
To: "Dominique Hazael-Massieux" <dom@w3.org>, public-device-apis <public-device-apis@w3.org>
Message-ID: <op.u4cwq0wobyn2jm@galactica>
On Thu, 03 Dec 2009 10:46:10 +0100, Dominique Hazael-Massieux <dom@w3.org>  
wrote:

> Hi,
>
> Arve raised yesterday during the call a notion that had been raised
> before: that instead of defining a new interface to grant access to the
> capture devices, we could rely on <input type="file"> with an accept
> attribute set to "video/*", "image/*" or "audio/*"; we would then rely
> (presumably) on a specialized File interface to get access to some
> additional metadata (presumably spatial and time dimensions).
>
> Some people have voiced concerns about that approach; in the hope of
> facilitating the discussion on this, I have tried to summarize what I
> have understood of the pros and cons of both approach (completed with a
> variant of the <input type="file">, <input type="photo">) on the wiki:
> http://www.w3.org/2009/dap/wiki/CaptureVsInput
>
> I hope this can help making progress in that discussion.
>
> As always, feedback on and additions to this comparison are welcome.

Thanks a bunch for compiling the table, this is useful.

Some comments:

<input type="file" accept="…">, In widgets:

This is currently marked as "awkward to use", not really, an example:

<input id="someForm" type="file" accept="image/*" data-foo="bar"><!-- foo  
and bar is something that to provide a hint to the UA to not launch a file  
chooser, but rather the camera app)
<script>
   var ele = document.getElementById('someForm');
   ele.onchange = function() {
     /* Code that handles the changed input, this could be either  
submitting the form, or using FileReader to get the actual content */
   }
   ele.click();
</script>

In an untrusted context, the code would work the same way, except the user  
would have to click himself.  If the context is somehow trusted [1],  
ele.click() does the trick.

The advantage of this approach is that in the "let's grab a picture and  
upload it", this already works without modification. It works on  
camera-less devices, and when FileReader/File is widely deployed by User  
Agents, it will work with very little applied magic.

This is no more awkward than the proposed Capture API

___
[1] I'm leaving the "trust" bit as an exercise to the reader, or a UA  
implementation detail, not as a "policy" question for now.

-- 
Arve Bersvendsen

pera Software ASA, http://www.opera.com/
Received on Thursday, 3 December 2009 10:01:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:14:02 GMT