Audio Support

Many applications provide support for ambient or event-based audio in the form of background music or sound effects. The use of sound is particularly strong in games—both immersive 3D experiences and tile- or sprite-based 2D games. Audio support makes a lot of sense for Cocoa Touch applications. After all, the iPhone is more a descendant of the iPod than a cellular phone, and the iPod Touch is positioned primarily as a media player.

Users often wear headphones when working with the devices, making the barrier to experience quite low. The media player role of the devices can dissuade developers from adding audio support to their applications—after all, when users are wearing headphones, they are likely listening to music or making a phone call and are thus opening an application for some secondary purpose.

There are two approaches to handling audio with Cocoa Touch. The first approach is to interrupt audio playback by other applications. For example, if you develop an application that records sound using the microphone, you may want to stop playback of music running in the iPod application.

The second approach is to mix audio from your application with audio from other running applications, such as the built-in iPod application. This approach treats audio more as an enhancement than a requirement, and is preferable for applications that don’t focus primarily on audio. Using the sound recorder example, you might allow the iPod to continue to play music so that users ...

Get Programming the iPhone User Experience now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.