Working with Audio in iOS Apps
Specifically there are two different ways iOS has for implementing audio. One is an instance of the AVAudioPlayer class—called, appropriately enough, an audio player—which provides playback of audio data from a file or memory.
You use this class unless you’re playing audio captured from a network stream or in need of very low I/O latency (lag time). The AVAudioPlayer class offers quite a lot of functionality, including playing sounds of any duration, looping sounds, playing multiple sounds simultaneously, and having one sound per audio player with precise synchronization among all the players in use.
It also controls relative playback level, stereo positioning, and playback rate for each sound you’re playing.
The AVAudioPlayer class lets you play sound in any audio format available in iOS. You implement a delegate to handle interruptions (such as an incoming SMS message) and to update the user interface when a sound has finished playing. The delegate methods to use are described in the AVAudioPlayerDelegate Protocol Reference (which you can access in the Organizer window).
The second way to play sound is by using System Sound Services, which provides a way to play short sounds and make the device vibrate. You can use System Sound Services to play short (30 seconds or shorter) sounds.
The interface doesn’t provide level, positioning, looping, or timing control and doesn’t support simultaneous playback: You can play only one sound at a time. You can use System Sound Services to provide audible alerts; on some iOS devices, alerts can even include vibration.