Inherits from NSObject
Conforms to AVAudioSessionDelegate
CDAudioInterruptProtocol
CDLongAudioSourceDelegate
Declared in CDAudioManager.h

Overview

CDAudioManager manages audio requirements for a game. It provides access to a CDSoundEngine object for playing sound effects. It provides access to two CDLongAudioSource object (left and right channel) for playing long duration audio such as background music and narration tracks. Additionally it manages the audio session to take care of things like audio session interruption and interacting with the audio of other apps that are running on the device.

Requirements: – Firmware: OS 2.2 or greater – Files: CDAudioManager., CocosDenshion. – Frameworks: OpenAL, AudioToolbox, AVFoundation

Tasks

Properties

backgroundMusic

soundEngine

willPlayBackgroundMusic

Class Methods

configure:

Configures the shared singleton with a mode

+ (void)configure:(tAudioManagerMode)mode

Declared In

CDAudioManager.h

end

Shuts down the shared audio manager instance so that it can be reinitialised

+ (void)end

Declared In

CDAudioManager.h

initAsynchronously:

Initializes the engine asynchronously with a mode

+ (void)initAsynchronously:(tAudioManagerMode)mode

Declared In

CDAudioManager.h

sharedManager

Returns the shared singleton

+ (CDAudioManager *)sharedManager

Declared In

CDAudioManager.h

sharedManagerState

Instance Methods

applicationDidBecomeActive

Call if you want to use built in resign behavior but need to do some additional audio processing on become active.

- (void)applicationDidBecomeActive

Declared In

CDAudioManager.h

applicationWillResignActive

Call if you want to use built in resign behavior but need to do some additional audio processing on resign active.

- (void)applicationWillResignActive

Declared In

CDAudioManager.h

audioSessionInterrupted

audioSessionResumed

audioSourceForChannel:

Retrieves the audio source for the specified channel

- (CDLongAudioSource *)audioSourceForChannel:(tAudioSourceChannel)channel

Declared In

CDAudioManager.h

audioSourceLoad:channel:

Loads the data from the specified file path to the channel’s audio source

- (CDLongAudioSource *)audioSourceLoad:(NSString *)filePath channel:(tAudioSourceChannel)channel

Declared In

CDAudioManager.h

init:

Initializes the engine synchronously with a mode, channel definition and a total number of channels

- (id)init:(tAudioManagerMode)mode

Declared In

CDAudioManager.h

isBackgroundMusicPlaying

Returns whether or not the background music is playing

- (BOOL)isBackgroundMusicPlaying

Declared In

CDAudioManager.h

isDeviceMuted

Returns true is audio is muted at a hardware level e.g user has ringer switch set to off

- (BOOL)isDeviceMuted

Declared In

CDAudioManager.h

isOtherAudioPlaying

Returns true if another app is playing audio such as the iPod music player

- (BOOL)isOtherAudioPlaying

Declared In

CDAudioManager.h

pauseBackgroundMusic

Pauses the background music

- (void)pauseBackgroundMusic

Declared In

CDAudioManager.h

playBackgroundMusic:loop:

Plays music in background. The music can be looped or not It is recommended to use .aac files as background music since they are decoded by the device (hardware).

- (void)playBackgroundMusic:(NSString *)filePath loop:(BOOL)loop

Declared In

CDAudioManager.h

preloadBackgroundMusic:

Preloads a background music

- (void)preloadBackgroundMusic:(NSString *)filePath

Declared In

CDAudioManager.h

resumeBackgroundMusic

Resumes playing the background music

- (void)resumeBackgroundMusic

Declared In

CDAudioManager.h

rewindBackgroundMusic

Rewinds the background music

- (void)rewindBackgroundMusic

Declared In

CDAudioManager.h

setBackgroundMusicCompletionListener:selector:

setMode:

Sets the way the audio manager interacts with the operating system such as whether it shares output with other apps or obeys the mute switch

- (void)setMode:(tAudioManagerMode)mode

Declared In

CDAudioManager.h

setResignBehavior:autoHandle:

stopBackgroundMusic

Stops playing the background music

- (void)stopBackgroundMusic

Declared In

CDAudioManager.h