- Codecs"There are two groups of playback codecs in iOS. The first group, listed in Table 2-3, includes highly efficient formats that you can use without restriction. That is, you can play more than one instance of each of these formats at the same time."

The Problem: Had 4 audio files that needed to be played depending on the stage the user was in the App. During the transition from one audio files to another, the sound needs to crossfade.

The solution:

1. For simplicity created 4 AVAudioPlayer class members as such: (can be done with 2 but the logic gets more complicated)

[code]

#import "MyPlayer.h"

#import <AVFoundation/AVFoundation.h>

@interface ImageExampleViewController : UIViewController {

MyPlayer *audioPlayerForest;

MyPlayer *audioPlayerForestCalm;

MyPlayer *audioPlayerCamp;

MyPlayer *audioPlayerTown;

}

@property(nonatomic , retain)MyPlayer *audioPlayerForest;

@property(nonatomic , retain)MyPlayer *audioPlayerForestCalm;

@property(nonatomic , retain)MyPlayer *audioPlayerCamp;

@property(nonatomic , retain)MyPlayer *audioPlayerTown;

@end

[/code]

2. MyPlayer is a subclass of AVAudioPlayer with one additional property storing the state of the sound: