Developing Android Applications with Adobe AIR [76]
video.x = 100;
video.y = 100;
video.attachCamera(camera);
addChild(video);
}
Note that frames are only captured when the application is in the foreground. If the application moves to the background, capturing is paused but will resume automatically when the application moves to the foreground again.
You can query for the camera properties. Here are a few queries which may be helpful in your development:
camera.height;
camera.width;
camera.bandwidth;
camera.fps;
camera.muted
camera.name
Documentation and Tutorials
Development around video is constantly evolving. The following two resources are among those that will help you to stay informed:
The Open Source Media Framework (http://www.opensourcemediaframework.com/resources.html) helps developers with video-related products. It is a good place to find code samples, tutorials, and other materials.
Lisa Larson-Kelly specializes in web video publishing and, more recently, mobile publishing. She offers free tutorials and a newsletter on the latest technology (http://learnfromlisa.com/).
Conclusion
Adobe’s effort toward video delivery on mobile devices using AIR has inspired Adobe engineers to revisit Flash Player. We will come back to this point in Chapter 14.
Flash Player 10.2 offers the new flash.media.StageVideo class to render video much more quickly. Unlike the traditional Video object, which is a displayObject, this class is not part of the stage but sits behind it. It relies on video hardware for both decoding and rendering. Instead of having the CPU read back from the GPU to render the video, the GPU now renders the video directly on the display.
For more information, read Thibault Imbert’s article at http://www.adobe.com/devnet/flashplayer/articles/stage_video.html.
At the time of this writing, this technology is currently only available in Flash Player, but it should be available in AIR for Android by summer 2011.
Chapter 13. StageWebView
The Internet is becoming the town square for the global village of tomorrow.
—Bill Gates
WebKit is a layout engine that browsers use to render web pages and to support interactivity and navigation history. Developed by Apple in 2002 and open sourced in 2005, WebKit is the default browser built in for Android.
The AIR runtime for the desktop also includes a version of WebKit built in. However, AIR for Android does not include it, and instead leverages the device’s native implementation and gives you access to some of its features via StageWebView.
StageWebView brings the benefits of an Internet browser to your own application. In this chapter, we will briefly discuss accessing the native browser, and then go over what StageWebView has to offer.
The Native Browser
To access the Internet, you need to set the permission for it:
You can launch the Android native browser from an AIR application using the navigateToURL method. You pass a URL in the same way you do on AIR for the desktop:
function onPublicNews():void {
navigateToURL(new URLRequest("http://www.npr.org"));
}
You can also use this method to launch native applications, such as the Android Market, that in turn makes calls to the Internet. The following example opens the Android Market and sets the criteria of applications to display as a URLRequest. Note that the protocol used is market:// instead of http://:
function onSearchMarket():void {
navigateToURL(new URLRequest("market://search?q=food"));
}
In both cases, your application moves to the background and the native browser becomes the active application.
We need, instead, a solution whereby HTML content can be embedded inside an AIR for Android application. This is what the StageWebView class does.
The StageWebView Class
The flash.media.StageWebView uclass is a new class for displaying and interacting with rich HTML content in an AIR for Android application. It is a subclass of the EventDispatcher class.
The flash.media.StageWebView class uses