Native webcam support and orientation events - technology preview
By Rich Tibbettrichtr. Wednesday, March 23, 2011 10:01:32 AM
Last week we wrote a blog post discussing our internal prototyping of web camera streaming in the browser. On the very same day, the proposed standard interface on which that was built changed considerably.
In addition to web camera streaming, Opera is also previewing support for the draft W3C Orientation Events specification. These capabilities open up some exciting possibilities for the future of the web itself.
To get started, grab the Android build and follow the installation instructions below:
- Go to the Android settings and ensure that "Unknown sources" (Allow install of non-Market application) is allowed.
- Download the build (.apk) from the provided location. Alternatively, you can download the build with a desktop browser, save it on a device, and install it using any available file manager.
- To launch this technology preview, find the installed Android application called "Opera Mobile - Device/Orientation demo".
To navigate back to this blog post, we added a camera icon on the Opera Speed Dial that will direct you back to this URL as a jumping off point for exploring more demos.
This build will not replace the standard version of Opera Mobile installed on your Android device. Furthermore, this build supports remote debugging via Opera Dragonfly; please refer to Dev.Opera for more instructions.Interacting with the camera
Developers are able to request a real-time video stream of the device's back-facing camera. The resulting camera stream may be displayed in any web page by assigning the success callback's return parameter to a HTML <video> element.
The simple example below demonstrates how this technology can be used to display the web camera in a web page:
The code above will render as follows:
More simple live web camera demos are available here.Opera's implementation
We have simplified the proposed GeneratedStream interface by not implementing its proposed methods and attributes. The Stream object returned in the success callback should be assigned directly to a video element's src attribute. When a video element's src parameter has been assigned a Stream object and that attribute is subsequently queried the attribute returns the reserved, though unresolvable, URI of about:streamurl.
We are currently in the process of considering different user experiences to ensure that the user can opt-in and authorize the sharing of their web camera with a web page. In the absence of this user opt-in functionality, we have currently chosen to disable access to any Stream pixel data via a HTML <canvas> element in this preview build. Developers can, however, override this restriction for prototyping purposes by entering opera:config in the URL bar, selecting 'Security Prefs' and then checking the option to 'Allow Camera to Canvas Copy' followed by 'Save'.Interacting with device orientation
Here's an example of using orientation events to create a simple compass:
The code above will render as follows:
We have also created a few other live orientation demos that you should check out.Next steps
It is likely that the standards around web camera access and streaming (and to a lesser extent, orientation events) will continue to evolve before this technology can become ubiquitous on the web. That's what happens when you're on the bleeding edge of technology. It's where we like to be.
We plan to:
- Add support for other major mobile and desktop platforms.
- Continue to actively participate in the related standards process to ensure this functionality becomes ubiquitous across the whole web and available in all browsers and web runtimes.
- Support microphone streams and allow assignment of those streams to
- Build user interfaces, both on desktop and mobile, that enable the user to explicitly opt-in to web camera sharing and opt-out or modify their web camera sharing once initial authorization has been provided to a web page.
- Continue prototyping towards enabling peer-to-peer audio and video communications in open web technologies.
- Prototype on how we can expose other aspects of the local device (e.g. mounted file systems) to end users in a privacy-secure way.
Our current prototyping demonstrates one well-known method for web camera access although the methods used to access device functionality (and to a lesser extent, orientation events) *will* change significantly before they are adopted as ubiquitous web standards.
Disclaimer: This build is of pre-production quality and, therefore, might contain defects including, but not limited to, instabilities and crashes. In fact, it may not work at all. The features included in this build might be different from any final standards implementation.
Give us your feedback in the comments below. We look forward to hearing about the great demos and services you come up with!