Blog Posts

The Case of iOS Background Audio

As a developer of media application on OSX and iOS, I am always developing on the cutting edge of what hardware can do and what not. And sometimes I am running into difficulties making a feature run solid and reliable. In media applications, there are a lot of issues you have to face and solve and most of the time the Apple media API documentation explains things not nearly enough. So most of the time I am stuck testing out application behavior on various devices and OS versions. In the case of Continuous Playback in Instacast, I released the feature without the proper deep testing, because initially on my iPhone 4 the feature was running well and I did not think that I would have so much trouble with it. But now after having some feedback from my customers I found out that there is a lot of stuff I've overlooked and that complicates the matter a lot.

So what's the problem? iOS supports playing audio even when an app is running in the background. But, and this is not in the documentation as far as I can see, initializing playback in the background is not supported (according to Apple technical support). That means it is impossible for a 3rd party app on iOS to run in the background and start playing a new song. However in iOS 4 initializing playback of audio files that are stored locally seems to work, but only if you use a lower-level playback component called AVPlayer. In Instacast 1.3 I switched to MPMoviePlayerController to make Video AirPlay possible, but this also broke the Continuous Playback feature completely. Continuous Playback from the background also does not work with streaming content and video material.

The situation in iOS 5 is much worse. As of iOS 5 Beta 3 the backgrounding behavior of 3rd party apps has changed. Now, as soon as you lock the device screen, the application is transitioned into background mode, even if the app is the front most one. This means Continuous Playback in iOS 5 only works if Instacast is the active application and if the device screen is not locked. This basically means, that the feature is unusable and does not make any sense at all.

So what are my next actions? Currently Continuous Playback in Instacast 1.3.1 is not reliable. If it wants to start streaming audio and video and the app is not the front most one, playback won't start and you only get a black screen. Over the last two days I was working on a fix that does not make the feature totally unusable:

  • Video episodes won't get played continuously and must be started manually every time.
  • If the app won't be able to start the next episode, playback is stopped altogether.
  • I submitted bug reports to Apple for the stuff that has been changed in iOS 5. Let's hope they consider reverting the behavior.
  • I am also considering to give you an optional local notification when Continuous Playback failed to start the new episode.

As a golden rule in iOS 4 you won't have any trouble if you keep Instacast the front most app when you're on a podcast listening marathon. Then there shouldn't be any problems. As an iOS 5 user should not lock your device screen, however I don't know if this advice is very usable.

Maybe you have some other ideas. Give me your feedback on Twitter.

July 21st, 2011 • Permalink


More articles about Blog Posts

05/09/2012 - New Specs on Podlove.org
05/09/2012 - Excellent Write-up of Instacast 2.0
05/07/2012 - Instacast 2.0 Available
05/06/2012 - Instacast HD Rejected over Flattr Integration
05/02/2012 - Multi-Format Podcast Feeds
04/26/2012 - Instacast 2.0 First Impressions
04/05/2012 - Patching iCloud Sync
03/29/2012 - The Podlove Initiative
03/28/2012 - Auphonic now Open for the Public
03/26/2012 - What's next with Instacast?
03/26/2012 - State of Support and iCloud