Posts Tagged ‘Mobile’

Background Audio Playback for mobile Adobe AIR apps!

Tuesday, October 18th, 2011

If you build a mobile Adobe AIR app to play or stream audio, the user expects that the music continues to playback when the app goes in the background. When I developed ON AIR powered by Last.fm (Last.fm application using Adobe AIR and targeting tablet devices), had to solve this problem.

Dependent mobile platform, you have to do different things to enable the audio playback in the background!

BlackBerry PlayBook Tablet OS

The PlayBook normally pauses your app, when the app is going into the background and stops everything including the playback of the audio. This is the default behaviour. QNX (Part of RIM/BlackBerry) provides two ActionScript3 libraries which allows to the OS UI Components (qnx-screens.swc) in your app or use OS features or capabilities like QNXSystemPowerMode (qnx-air.swc). These libraries will be shipped with the latest version 4.5.1 of Flash Builder. To add the BlackBerry ActionScript Libraries to the project, you have to enable a property “Add platform specific libraries to library path” in the Project Properties (Flex Build Packaging -> BlackBerry Tablet OS).

After enabling the libraries, you only have to add the following lines which sets the PowerMode when the app inactive in the background to THROTTLED.

import qnx.system.QNXSystem;
import qnx.system.QNXSystemPowerMode;

qnx.system.QNXSystem.system.inactivePowerMode = QNXSystemPowerMode.THROTTLED;

In the PowerMode THROTTLED, the AIR runtime is stopping the rendering but still executes the code to playback the audio.

Here is the documentation about the PowerMode of QNX.

Google Android

On Android, the audio playback in the background is dependent of the device OS version. As multitasking on Android is available since version 3.0 (Honeycomb), only apps running on devices using Honeycomb or later will playback audio in the background.

To ensure that the app is still running when the user isn’t doing anything, you should add following line to keep the app awake.

NativeApplication.nativeApplication.systemIdleMode=SystemIdleMode.KEEP_AWAKE;

Here is the corresponding ActionScript3 documentation. To enable the AIR app to change system idle, the Android part of the AIR App Descriptor file has to contain the following uses permessions.

<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>

Apple iOS

Normally, an AIR app (or native app) on iOS is stopping the audio playback when the app is going in the background. With Adobe AIR 3.0, you can enable the Background Audio Playback for AIR application. Add the parameter UIBackgroundModes with the value audio to the iOS part of the app descriptor of your application.

<iPhone>
 <InfoAdditions>
  <![CDATA[
   <key>UIBackgroundModes</key>
   <array>
    <string>audio</string>
   </array>
  ]]>
 </InfoAdditions>
</iPhone>

Currently, AIR 3.0 has problem with the screen lock of iOS, which is disabling the background audio playback.
To prevent the screen lock on iOS, your app should use the System Idle Mode KEEP_AWAKE.

NativeApplication.nativeApplication.systemIdleMode=SystemIdleMode.KEEP_AWAKE;


Last.fm ON AIR is available for BlackBerry PlayBook, Android Tablets and Apple iPad now!

Thursday, September 1st, 2011

Finally, last night the last App Store approved my application. Last.fm ON AIR is available at all three App Store: BlackBerry AppWorld, Android Market and Apple iTunes AppStore.

Information about all my Last.fm projects include the Last.fm ON AIR can be found on my Labs page.

Last.fm ON AIR allows you to search or listen to your favorite artists, tracks or albums. You manage your music library and scrobble the music you currently listen. Find nearby events and upload your tagged event photos directly to Flickr linked to the Last.fm event page.

A Last.fm subscription (PAID) is necessary to use the radio capabilities of the application.

The application provides following functionality:

  • Listen to stations and Scrobbling (Paid Subscriber Only!)
  • Love and Ban Tracks
  • Add Artists, Albums and Tracks to your Library.
  • Search and Viewing informations about: Artists, Albums, Tracks, Events and Users
  • Attending Events
  • Landscape and Portrait Mode
  • Location based services (Find Events)
  • Uploading tagged Event Photos to Flickr
  • Add support for shouts
  • Device Integration: Use the buttons of the device to control application (Play/Pause/Skip/Change Volume). (Only BlackBerry PlayBook)
  • Open Music store to buy and search for artists, tracks and albums. (Only BlackBerry PlayBook)

Here are the links to the application Last.fm ON AIR at the different App Stores.





I also created a group on Last.fm, where you post and share infos: Submit bugs, make feature requests, etc…
http://www.lastfm.de/group/Last.fm+ON+AIR

Credits

Thanks to the Last.fm team for allowing me to use their logo for my application.

Development and Design

The application is based on Adobe AIR 2.7 using Flex 4.5.1, which is optimzed for iOS application for Adobe AIR. As part of this project, I created my own Flex Library for the Last.fm. This library is implementing the latest Last.fm webservice API using OpenSource Flex MVC Framework Parsley. I will release this library as soon as I have finished the documentation for it.

For Design, I used Adobe Illustrator and Adobe Photoshop. I also used Adobe Flash Catalyst for my transforming my design into assets, because Flash Catalyst is a great tool to convert assets into FXG files for ActionScript Skins(Create Workflow to create FXG assets for ActionScript Skins). The reason why I didn’t used Illustrator for step is that I found no way to export multiple FXG files from Illustrator file.

In the next days, I will write some blog post about what I learned in this project. For example: How to create Progressbar for Mobile AIR applications.

First version of PlayBook Device Simulation released!

Tuesday, February 22nd, 2011

Today, I released little private project “PlayBook Device Simulation” that allows to use PlayBook specific API when develop with the AIR Debug Launcher (ADL). The solution consists of two parts: an ActionScript3 Library (PlayBook Device Simulation) and an AIR application (PlayBook Device Simulator).

I ported some of the classes of the QNX AIR Library, so that the classes have some functions and variables (1:1). Currently supported classes and features: AudioManager, Device, MediaServiceConnection and QNXApplication. My solutions supports features, which can’t be test with the VMware Image of the PlayBook Device Simulator, like Power Management (Battery).  Another reason to test the solution is that won’t get any error messages (VerifyError: Error #1014: Class qnx.pps::PPSChannel could not be found) when using any of the supported classes.

Technically, I’m using the ServerSocket API of Adobe AIR to connect the Mobile AIR Application with the PlayBook Device Simulator. This allows a two communication between the Mobile AIR Application and the simulator.

Additional information about integration and usage can be found on the project site: http://www.patrick-heinzelmann.de/labs/playbookdevicesimulation

Flex Framework for mobile applications

Thursday, October 8th, 2009

Adobe is working on a version of the Flex framework for mobile application, Codemane Slider. When I watched the video about the Slider Preview at Max presentation by Ely Greenfield (Adobe), I was totally impressed about the ideas behind Slider. I like the idea how to solve the to integrate into multiple plattforms and Cross Platform developement based on Conditions and Style/Skins. If you want to now what I’m talking about, check the video below. Adobe provides also a white paper at Adobe Labs.