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
-
soundEngineproperty -
backgroundMusicproperty -
willPlayBackgroundMusicproperty -
+ sharedManagerReturns 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: -
– isDeviceMutedReturns true is audio is muted at a hardware level e.g user has ringer switch set to off
-
– isOtherAudioPlayingReturns 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
-
+ endShuts down the shared audio manager instance so that it can be reinitialised
-
– applicationWillResignActiveCall if you want to use built in resign behavior but need to do some additional audio processing on resign active.
-
– applicationDidBecomeActiveCall 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
-
– stopBackgroundMusicStops playing the background music
-
– pauseBackgroundMusicPauses the background music
-
– rewindBackgroundMusicRewinds the background music
-
– resumeBackgroundMusicResumes playing the background music
-
– isBackgroundMusicPlayingReturns whether or not the background music is playing
-
– setBackgroundMusicCompletionListener:selector:
Class Methods
configure:
Configures the shared singleton with a mode
+ (void)configure:(tAudioManagerMode)modeDeclared In
CDAudioManager.hend
Shuts down the shared audio manager instance so that it can be reinitialised
+ (void)endDeclared In
CDAudioManager.hinitAsynchronously:
Initializes the engine asynchronously with a mode
+ (void)initAsynchronously:(tAudioManagerMode)modeDeclared In
CDAudioManager.hInstance Methods
applicationDidBecomeActive
Call if you want to use built in resign behavior but need to do some additional audio processing on become active.
- (void)applicationDidBecomeActiveDeclared In
CDAudioManager.happlicationWillResignActive
Call if you want to use built in resign behavior but need to do some additional audio processing on resign active.
- (void)applicationWillResignActiveDeclared In
CDAudioManager.haudioSourceForChannel:
Retrieves the audio source for the specified channel
- (CDLongAudioSource *)audioSourceForChannel:(tAudioSourceChannel)channelDeclared In
CDAudioManager.haudioSourceLoad:channel:
Loads the data from the specified file path to the channel’s audio source
- (CDLongAudioSource *)audioSourceLoad:(NSString *)filePath channel:(tAudioSourceChannel)channelDeclared In
CDAudioManager.hinit:
Initializes the engine synchronously with a mode, channel definition and a total number of channels
- (id)init:(tAudioManagerMode)modeDeclared In
CDAudioManager.hisBackgroundMusicPlaying
Returns whether or not the background music is playing
- (BOOL)isBackgroundMusicPlayingDeclared In
CDAudioManager.hisDeviceMuted
Returns true is audio is muted at a hardware level e.g user has ringer switch set to off
- (BOOL)isDeviceMutedDeclared In
CDAudioManager.hisOtherAudioPlaying
Returns true if another app is playing audio such as the iPod music player
- (BOOL)isOtherAudioPlayingDeclared In
CDAudioManager.hpauseBackgroundMusic
Pauses the background music
- (void)pauseBackgroundMusicDeclared In
CDAudioManager.hplayBackgroundMusic: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)loopDeclared In
CDAudioManager.hpreloadBackgroundMusic:
Preloads a background music
- (void)preloadBackgroundMusic:(NSString *)filePathDeclared In
CDAudioManager.hresumeBackgroundMusic
Resumes playing the background music
- (void)resumeBackgroundMusicDeclared In
CDAudioManager.hrewindBackgroundMusic
Rewinds the background music
- (void)rewindBackgroundMusicDeclared In
CDAudioManager.h