After understanding some ways of integrating audio in the app, the most commonly used and easiest way is AVAudioPlayer. Basically, in this recipe, we will be adding background music, which will be running forever, and some sound effects on specific events where the user's attention is required or where the user has to be notified of some change. This adding of background music and sound effects will be done in our game FlyingSpaceship built in the previous chapters.
Before starting with the addition of background music and sound effects on some events, we should have a good understanding of the
AVAudioPlayer class and the
AVFoundation framework. So the prerequisite for this section is to have knowledge ...