CDAudioManager Class Reference
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
-
soundEngine
property -
backgroundMusic
property -
willPlayBackgroundMusic
property -
+ sharedManager
Returns the shared singleton
-
+ sharedManagerState
-
+ configure:
Configures the shared singleton with a mode
-
+ initAsynchronously:
Initializes the engine asynchronously with a mode
-
– init:
Initializes the engine synchronously with a mode, channel definition and a total number of channels
-
– audioSessionInterrupted
-
– audioSessionResumed
-
– setResignBehavior:autoHandle:
-
– isDeviceMuted
Returns true is audio is muted at a hardware level e.g user has ringer switch set to off
-
– isOtherAudioPlaying
Returns true if another app is playing audio such as the iPod music player
-
– 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
-
+ end
Shuts down the shared audio manager instance so that it can be reinitialised
-
– applicationWillResignActive
Call if you want to use built in resign behavior but need to do some additional audio processing on resign active.
-
– applicationDidBecomeActive
Call if you want to use built in resign behavior but need to do some additional audio processing on become active.
-
– audioSourceLoad:channel:
Loads the data from the specified file path to the channel’s audio source
-
– audioSourceForChannel:
Retrieves the audio source for the specified channel
-
– 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).
-
– preloadBackgroundMusic:
Preloads a background music
-
– stopBackgroundMusic
Stops playing the background music
-
– pauseBackgroundMusic
Pauses the background music
-
– rewindBackgroundMusic
Rewinds the background music
-
– resumeBackgroundMusic
Resumes playing the background music
-
– isBackgroundMusicPlaying
Returns whether or not the background music is playing
-
– setBackgroundMusicCompletionListener:selector:
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
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
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