Perform the following steps to start the audio engine:
Open our Xcode project if it's not already open.
Switch to the
Game.m
file.Inside the initializer, start the audio engine as shown; it should be one of the first few statements:
[SPAudioEngine start];
Add a
dealloc
method that stops the audio engine:-(void) dealloc { [SPAudioEngine stop]; }
Run the example.
When we run this example in the simulator, we might see the following lines in the console:
To play any audio file, we need to start the audio engine at the start of our application, which in our case, is the initializer from the Game
class.
There are different operational modes for the audio engine, which influence how the iPod music app will behave when we run our game.
If the audio is muted, the game audio will be muted as well. This is the default operational mode; other modes include the game audio continue even when the device is muted or the iPod music mixes with...