A core vision of Gears is that the same APIs are available on the desktop, and mobile versions.
That being said, there are APIs that will potentially make more sense on one platform or another. One of those that has garnered excitement on the mobile platform is the Location API.
Another is the newly proposed Camera API that “enables a script to trigger the camera viewfinder and allow a picture or video to be captured using the device’s onboard camera.”
That being said, this could still tie into a computers webcam.
Summary
The goal of this API is to allow a Web application to launch the native camera application and obtain the resulting media file.
On devices with built-in camera, all of the UI interaction is left to the corresponding native camera application, not Gears.
On devices that do not have a built-in camera (e.g. laptop or desktop computers), Gears will scan for attached Web cameras and will provide a basic viewport that allows the users to grab a picture or record a movie. If several cameras are attached, Gears will provide a way for the users to select the device they want to use.
This API is based on the “action-driven permission model” – the user is involved in the action and hence a separate permission prompt is not required.
You would use the API like this:
// Create a camera object var camera = google.gears.factory.create("beta.camera"); // Capture an image. var image = camera.captureImage(function(media) { uploadImage(media.content); }); // Capture of a video, specifying a desired resolution and duration. var video = camera.captureVideo(function(media) { uploadVideo(media.content); }, 5000);
The full API proposal is:
interface Camera { // Acquisition methods // Triggers the camera viewfinder and invokes the callback after the user // has either captured the image or canceled the operation. void captureImage(CaptureCallback callback, optional CaptureOptions options); // Triggers the camera viewfinder and invokes the callback after the user // has either captured the video, canceled the operation or maxDuration milliseconds // have elapsed. void captureVideo(CaptureCallback callback, double maxDuration, optional CaptureOptions options); // Query methods Array availableImageFormats(); Array availableVideoFormats(); }; void CaptureCallback(Media media); interface CaptureOptions { string format; // MIME type double width; // desired image or video frame width double height; // desired image or video frame height }; interface Media { readonly string format; // MIME type readonly double width; readonly double height; readonly Blob content; // reference to captured media };
What do you think? What haven’t we thought about yet?
Other Future APIs
- Resumable Uploads via PUT/POST
- Open ID and OAuth
- Services / Daemon API
- Notification API
- Crypto API
- Developer Tools
- Factory API updates
- Blob API
- Logging API
- Messaging API
- Location API
- Desktop Shortcut API
- Image Manipulation API
- Introduction to the series
Disclaimer: These APIs are being discussed by the Gears community and do not represent live products. Do you have ideas for cool Gears that make the Web better? Let us know!.
June 3rd, 2008 at 2:01 pm
Nice, awesome! Right path!
ceo
June 3rd, 2008 at 6:00 pm
Why is height and width a double?
June 3rd, 2008 at 6:53 pm
HI, do you know if gears will be available for firefox3 sometime?
June 16th, 2008 at 9:51 am
Why not use input type=file for this? If some attribute is specified, say type=image/*, user agents could present that input field as [[Make Photo] [Select Photo]] to users. The Web Forms 2.0 proposals for getting the file data out of input type=file could be used for the rest.
December 9th, 2008 at 12:25 am
This is the greatest post I have come across so far.I am really pleased to post my comment on this blog .I love your blog by the way, I am gonna have to add you to my list of watched blogs .Thank you for this very useful information. stored it.Thanks again and keep up the good work.
February 11th, 2009 at 6:08 pm
“Video conferencing is great way to protect the environment by cutting down business trips as traveling does harm the air in some ways. Video conferencing to day is recognized as one of the approaches for a green environment.
“
July 29th, 2009 at 2:18 am
“What do you think? What haven’t we thought about yet?”
You should provide a callback when the picture-taking is triggered by the camera application, e.g. by pressing the camera button.
April 29th, 2010 at 10:48 am
How can I use this in my code? I mean to say… I want to make a web page that records users live web cam video on my server.What steps I should follow??