How to Develop AIR Video Applications for Android

This post is also available in: Russian

android video apps

Today, smart phones and tablets have become integral parts of our daily life. People interact with such devices frequently and lengthly over a day. So, mobile and tablet applications have become important channels for content distribution. Launching of virtually any major service includes ad-hoc application development. Segmentation of mobile applications greatly increases the cost to implement a mobile strategy. Adobe AIR allows you to reduce the cost-to-market for cross-platform services. You can develop your application once and then adapt it easily to a range of devices or screens (also, there’s more dexterous Flash developers on the market than iOS or Android experts). In this article, we’ll dwell on some features regarding development of mobile applications with Adobe AIR.

To choose a development technology, you should consider multiple factors. A crucial indicator is the cost of development and further support. Based on our expertise, Adobe AIR is more cost-efficient up to a certain level of application complexity. After a certain complexity level, the cost of developing and maintaining Adobe AIR applications is equal to or greater than the development of individual Native applications. This is due to several reasons, such as: runtime constraints, lack of access to parts of the system API (hence the need to develop Native Extensions requiring a sound native development expertise), runtime errors (which can not always be overcome by native extensions), and runtime differences between various platforms.

In our projects, we use both approaches. To my mind, both approaches are valid and can enable the quality of experience. However the opposite is also true, you might well develop a mean application with any kind of technology. In order not to limit video service developers, in the new release of Adobe Access 4.0, Adobe decided to include Native libraries to handle protected content under iOS and Android. However working with video is much easier in the standard Flash environment, where you have a multi-functional OSMF framework, established mechanisms to process multimedia content, and a well-designed architecture. In case of AIR-based video applications, you probably will not be able to avoid Native Extensions.
You’ll need the extensions to avoid certain runtime limitations or even issues. Also, Native Extensions may well be used to optimize application performance (although this is rarely needed).

Still, the Native Extensions mechanism implies some difficulties, at least initially. First of all, building of a Native Extension and its parent project is in no way trivial. You’ll need to compile your Native code, unzip the Flash SWC library, substitute a multitude of paths, build a new Flash library with embedded Native code, and manually edit the XML metadata in the manifest file. Moreover, you’ll have to do all this manually, as currently no integration with Flash Builder is supported (and there is no indication either that it ever would). Therefore, you’d better right away prepare a set of scripts to clean the project and compile your Native Extension.

For myself, I wrote two scripts: A project cleanup script (clean.sh) and the compilation script (compile.sh). Both of them are using a single configuration script (config.sh) containing paths. Sample config.sh

1
#!/bin/bash adt_directory=/Applications/Adobe\ Flash\ Builder\ 4.6/sdks/4.6.0/bin root_directory=~/Documents/DENIVIP\ Media/Project_Directory library_directory=${root_directory}/AndroidANELib native_directory=${root_directory}/Android/bin signing_options="-storetype PKCS12 -keystore ./keyfile.p12" dest_ANE=InAppANE.ane extension_XML=${library_directory}/src/extension.xml library_SWC=${library_directory}/bin/InAppANELibrary.swc

Sample compile.sh

1
#!/bin/bash source "config.sh" unzip "${library_directory}/bin/InAppANELibrary.swc" -d "${library_directory}/bin" cp "${library_directory}/bin/library.swf" "${native_directory}/library.swf" "${adt_directory}"/adt -package ${signing_options} -target ane "${dest_ANE}" "${extension_XML}" -swc "${library_SWC}" -platform Android-ARM -C "${native_directory}" .

Sample clean.sh

1
#!/bin/bash source "config.sh" rm "${library_directory}/bin/catalog.xml" rm "${library_directory}/bin/library.swf" rm "${native_directory}/library.swf" rm "${native_directory}/InAppPurchaseANE.jar"

The use of Native Extensions demands a solid understanding of the Native architecture. If you are using Android Native Extensions, then you’ll probably never be able to proceed without a general insight into the Android applications architecture and their interaction. As a starter, read the official documentation, giving special attention to such concepts as Activity, Intent, Receiver, and Service. To access the system resources, your applications should have special permissions, be able to start services using intents, and beyond. The same applies to the iOS applications.

Please find below our selection of Native Extensions for AIR Android applications that we think are most useful.

  • A system volume control (Volume ANE) is a pretty nice thing, as AIR can control only the relative volume inside the video player.
  • An interface to InApp Purchase (InApp Purchase ANE) is needed to support payment from an application (i.e., one-time purchase, subscription)
  • An interface to the push notification service (C2DM service ANE): you’ll need it to send messages to the application using the C2DM service
  • An interface to handle system notifications (Notifications ANE): you’ll need it to display system notifications

Here is a list of useful Native Extensions on the Adobe page.

While creating a video service for mobile devices, please also dedicate a decent amount of time to optimize your video content (that’s what all the bother was about). Mobile applications are limited in resources compared to personal computers, so in order to achieve optimum user experience, please follow the applicable guidelines for video content preparation. On the Internet, there’s a lot of resources on how to optimize video for mobile devices. Recently, the Adobe Developers Connection website published an amazing manual on optimizing video for iOS devices written by Maxim Levkov. Here is yet another manual on optimizing video for Android devices.

In a next article, we will look at how to optimize Android applications based on AIR. Stay connected!

Leave a Reply