cocos2d-x  3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CDAudioManager Class Reference

CDAudioManager manages audio requirements for a game. More...

#import <CDAudioManager.h>

Inheritance diagram for CDAudioManager:
<CDAudioInterruptProtocol> <CDLongAudioSourceDelegate> <CDAudioInterruptProtocol> <CDLongAudioSourceDelegate>

Instance Methods

(id- init:
 Initializes the engine synchronously with a mode, channel definition and a total number of channels. More...
 
(void) - audioSessionInterrupted
(void) - audioSessionResumed
(void) - setResignBehavior:autoHandle:
var - setResignBehavior:autoHandle:
local - setResignBehavior:autoHandle:
(BOOL) - isDeviceMuted
 Returns true is audio is muted at a hardware level e.g user has ringer switch set to off. More...
 
(BOOL) - isOtherAudioPlaying
 Returns true if another app is playing audio such as the iPod music player. More...
 
(void) - 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. More...
 
(void) - applicationWillResignActive
 Call if you want to use built in resign behavior but need to do some additional audio processing on resign active. More...
 
local - applicationWillResignActive
 Call if you want to use built in resign behavior but need to do some additional audio processing on resign active. More...
 
(void) - applicationDidBecomeActive
 Call if you want to use built in resign behavior but need to do some additional audio processing on become active. More...
 
(CDLongAudioSource *) - audioSourceLoad:channel:
 Loads the data from the specified file path to the channel's audio source. More...
 
(CDLongAudioSource *) - audioSourceForChannel:
 Retrieves the audio source for the specified channel. More...
 
(void) - playBackgroundMusic:loop:
 Plays music in background. More...
 
var - playBackgroundMusic:loop:
 Plays music in background. More...
 
local - playBackgroundMusic:loop:
 Plays music in background. More...
 
(void) - preloadBackgroundMusic:
 Preloads a background music. More...
 
(void) - stopBackgroundMusic
 Stops playing the background music. More...
 
(void) - pauseBackgroundMusic
 Pauses the background music. More...
 
(void) - rewindBackgroundMusic
 Rewinds the background music. More...
 
(void) - resumeBackgroundMusic
 Resumes playing the background music. More...
 
(BOOL) - isBackgroundMusicPlaying
 Returns whether or not the background music is playing. More...
 
(void) - setBackgroundMusicCompletionListener:selector:
(id- init:
 Initializes the engine synchronously with a mode, channel definition and a total number of channels. More...
 
(void) - audioSessionInterrupted
(void) - audioSessionResumed
(void) - setResignBehavior:autoHandle:
local - setResignBehavior:autoHandle:
(BOOL) - isDeviceMuted
 Returns true is audio is muted at a hardware level e.g user has ringer switch set to off. More...
 
(BOOL) - isOtherAudioPlaying
 Returns true if another app is playing audio such as the iPod music player. More...
 
(void) - 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. More...
 
(void) - applicationWillResignActive
 Call if you want to use built in resign behavior but need to do some additional audio processing on resign active. More...
 
(void) - applicationDidBecomeActive
 Call if you want to use built in resign behavior but need to do some additional audio processing on become active. More...
 
(CDLongAudioSource *) - audioSourceLoad:channel:
 Loads the data from the specified file path to the channel's audio source. More...
 
(CDLongAudioSource *) - audioSourceForChannel:
 Retrieves the audio source for the specified channel. More...
 
(void) - playBackgroundMusic:loop:
 Plays music in background. More...
 
var - playBackgroundMusic:loop:
 Plays music in background. More...
 
local - playBackgroundMusic:loop:
 Plays music in background. More...
 
(void) - preloadBackgroundMusic:
 Preloads a background music. More...
 
(void) - stopBackgroundMusic
 Stops playing the background music. More...
 
(void) - pauseBackgroundMusic
 Pauses the background music. More...
 
(void) - rewindBackgroundMusic
 Rewinds the background music. More...
 
(void) - resumeBackgroundMusic
 Resumes playing the background music. More...
 
(BOOL) - isBackgroundMusicPlaying
 Returns whether or not the background music is playing. More...
 
(void) - setBackgroundMusicCompletionListener:selector:
- Instance Methods inherited from <CDLongAudioSourceDelegate>
(void) - cdAudioSourceDidFinishPlaying:
 The audio source completed playing. More...
 
(void) - cdAudioSourceFileDidChange:
 The file used to load the audio source has changed. More...
 
(void) - cdAudioSourceDidFinishPlaying:
 The audio source completed playing. More...
 
var - cdAudioSourceDidFinishPlaying:
 The audio source completed playing. More...
 
local - cdAudioSourceDidFinishPlaying:
 The audio source completed playing. More...
 
(void) - cdAudioSourceFileDidChange:
 The file used to load the audio source has changed. More...
 
- Instance Methods inherited from <CDAudioInterruptProtocol>
(BOOL) - mute
 Is audio mute. More...
 
(void) - setMute:
 If YES then audio is silenced but not stopped, calls to start new audio will proceed but silently. More...
 
(BOOL) - enabled
 Is audio enabled. More...
 
(void) - setEnabled:
 If NO then all audio is stopped and any calls to start new audio will be ignored. More...
 
(BOOL) - mute
 Is audio mute. More...
 
(void) - setMute:
 If YES then audio is silenced but not stopped, calls to start new audio will proceed but silently. More...
 
local - setMute:
 If YES then audio is silenced but not stopped, calls to start new audio will proceed but silently. More...
 
(BOOL) - enabled
 Is audio enabled. More...
 
(void) - setEnabled:
 If NO then all audio is stopped and any calls to start new audio will be ignored. More...
 

Class Methods

(CDAudioManager *) + sharedManager
 Returns the shared singleton. More...
 
(tAudioManagerState+ sharedManagerState
(void) + configure:
 Configures the shared singleton with a mode. More...
 
(void) + initAsynchronously:
 Initializes the engine asynchronously with a mode. More...
 
(void) + end
 Shuts down the shared audio manager instance so that it can be reinitialised. More...
 
(CDAudioManager *) + sharedManager
 Returns the shared singleton. More...
 
var + sharedManager
 Returns the shared singleton. More...
 
(tAudioManagerState+ sharedManagerState
local + sharedManagerState
(void) + configure:
 Configures the shared singleton with a mode. More...
 
(void) + initAsynchronously:
 Initializes the engine asynchronously with a mode. More...
 
(void) + end
 Shuts down the shared audio manager instance so that it can be reinitialised. More...
 

Protected Attributes

NSMutableArray * audioSourceChannels
var audioSourceChannels
local audioSourceChannels
NSString * _audioSessionCategory
BOOL _audioWasPlayingAtStartup
tAudioManagerMode _mode
SEL backgroundMusicCompletionSelector
id backgroundMusicCompletionListener
BOOL _mute
BOOL _resigned
BOOL _interrupted
BOOL _audioSessionActive
BOOL enabled_
BOOL _isObservingAppEvents
tAudioManagerResignBehavior _resignBehavior

Properties

CDSoundEnginesoundEngine
CDLongAudioSourcebackgroundMusic
BOOL willPlayBackgroundMusic

Detailed Description

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:

Method Documentation

- (void) applicationDidBecomeActive

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

var applicationDidBecomeActive

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

local applicationDidBecomeActive

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

- (void) applicationDidBecomeActive

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

var applicationDidBecomeActive

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

local applicationDidBecomeActive

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

- (void)
applicationWillResignActive

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

var applicationWillResignActive

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

local applicationWillResignActive

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

- (void)
applicationWillResignActive

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

var applicationWillResignActive

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

local applicationWillResignActive

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

- (void) audioSessionInterrupted
var audioSessionInterrupted
local audioSessionInterrupted
- (void) audioSessionInterrupted
var audioSessionInterrupted
local audioSessionInterrupted
- (void) audioSessionResumed
var audioSessionResumed
local audioSessionResumed
- (void) audioSessionResumed
var audioSessionResumed
local audioSessionResumed
- (CDLongAudioSource*)
audioSourceForChannel:
(tAudioSourceChannel channel

Retrieves the audio source for the specified channel.

- (CDLongAudioSource*)
audioSourceForChannel:
var  channel

Retrieves the audio source for the specified channel.

- (CDLongAudioSource*)
audioSourceForChannel:
local  channel

Retrieves the audio source for the specified channel.

- (CDLongAudioSource*)
audioSourceForChannel:
(tAudioSourceChannel channel

Retrieves the audio source for the specified channel.

- (CDLongAudioSource*)
audioSourceForChannel:
var  channel

Retrieves the audio source for the specified channel.

- (CDLongAudioSource*)
audioSourceForChannel:
local  channel

Retrieves the audio source for the specified channel.

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

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

- (CDLongAudioSource*)
audioSourceLoad:
var  filePath
channel: var  channel 

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

- (CDLongAudioSource*)
audioSourceLoad:
local  filePath
channel: local  channel 

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

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

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

- (CDLongAudioSource*)
audioSourceLoad:
var  filePath
channel: var  channel 

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

- (CDLongAudioSource*)
audioSourceLoad:
local  filePath
channel: local  channel 

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

+ (void) configure: (tAudioManagerMode mode

Configures the shared singleton with a mode.

+ (void) configure: var  mode

Configures the shared singleton with a mode.

+ (void) configure: local  mode

Configures the shared singleton with a mode.

+ (void) configure: (tAudioManagerMode mode

Configures the shared singleton with a mode.

+ (void) configure: var  mode

Configures the shared singleton with a mode.

+ (void) configure: local  mode

Configures the shared singleton with a mode.

+ (void) end

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

var end

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

local end

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

+ (void) end

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

var end

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

local end

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

- (id) init: (tAudioManagerMode mode

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

- (id) init: var  mode

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

- (id) init: local  mode

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

- (id) init: (tAudioManagerMode mode

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

- (id) init: var  mode

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

- (id) init: local  mode

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

+ (void) initAsynchronously: (tAudioManagerMode mode

Initializes the engine asynchronously with a mode.

+ (void) initAsynchronously: var  mode

Initializes the engine asynchronously with a mode.

+ (void) initAsynchronously: local  mode

Initializes the engine asynchronously with a mode.

+ (void) initAsynchronously: (tAudioManagerMode mode

Initializes the engine asynchronously with a mode.

+ (void) initAsynchronously: var  mode

Initializes the engine asynchronously with a mode.

+ (void) initAsynchronously: local  mode

Initializes the engine asynchronously with a mode.

- (BOOL) isBackgroundMusicPlaying

Returns whether or not the background music is playing.

var isBackgroundMusicPlaying

Returns whether or not the background music is playing.

local isBackgroundMusicPlaying

Returns whether or not the background music is playing.

- (BOOL) isBackgroundMusicPlaying

Returns whether or not the background music is playing.

var isBackgroundMusicPlaying

Returns whether or not the background music is playing.

local isBackgroundMusicPlaying

Returns whether or not the background music is playing.

- (BOOL) isDeviceMuted

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

var isDeviceMuted

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

local isDeviceMuted

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

- (BOOL) isDeviceMuted

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

var isDeviceMuted

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

local isDeviceMuted

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

- (BOOL) isOtherAudioPlaying

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

var isOtherAudioPlaying

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

local isOtherAudioPlaying

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

- (BOOL) isOtherAudioPlaying

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

var isOtherAudioPlaying

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

local isOtherAudioPlaying

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

- (void) pauseBackgroundMusic

Pauses the background music.

var pauseBackgroundMusic

Pauses the background music.

local pauseBackgroundMusic

Pauses the background music.

- (void) pauseBackgroundMusic

Pauses the background music.

var pauseBackgroundMusic

Pauses the background music.

local pauseBackgroundMusic

Pauses the background music.

- (void) playBackgroundMusic: (NSString *)  filePath
loop: (BOOL)  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: var  filePath
loop: var  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: local  filePath
loop: local  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 

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: var  filePath
loop: var  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: local  filePath
loop: local  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) preloadBackgroundMusic: (NSString *)  filePath

Preloads a background music.

- (void) preloadBackgroundMusic: var  filePath

Preloads a background music.

- (void) preloadBackgroundMusic: local  filePath

Preloads a background music.

- (void) preloadBackgroundMusic: (NSString *)  filePath

Preloads a background music.

- (void) preloadBackgroundMusic: var  filePath

Preloads a background music.

- (void) preloadBackgroundMusic: local  filePath

Preloads a background music.

- (void) resumeBackgroundMusic

Resumes playing the background music.

var resumeBackgroundMusic

Resumes playing the background music.

local resumeBackgroundMusic

Resumes playing the background music.

- (void) resumeBackgroundMusic

Resumes playing the background music.

var resumeBackgroundMusic

Resumes playing the background music.

local resumeBackgroundMusic

Resumes playing the background music.

- (void) rewindBackgroundMusic

Rewinds the background music.

var rewindBackgroundMusic

Rewinds the background music.

local rewindBackgroundMusic

Rewinds the background music.

- (void) rewindBackgroundMusic

Rewinds the background music.

var rewindBackgroundMusic

Rewinds the background music.

local rewindBackgroundMusic

Rewinds the background music.

- (void)
setBackgroundMusicCompletionListener:
(id listener
selector: (SEL)  selector 
- (void)
setBackgroundMusicCompletionListener:
var  listener
selector: var  selector 
- (void)
setBackgroundMusicCompletionListener:
local  listener
selector: local  selector 
- (void)
setBackgroundMusicCompletionListener:
(id listener
selector: (SEL)  selector 
- (void)
setBackgroundMusicCompletionListener:
var  listener
selector: var  selector 
- (void)
setBackgroundMusicCompletionListener:
local  listener
selector: local  selector 
- (void) setMode: (tAudioManagerMode mode

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: var  mode

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: local  mode

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

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: var  mode

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: local  mode

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) setResignBehavior: (tAudioManagerResignBehavior resignBehavior
autoHandle: (BOOL)  autoHandle 
- (void) setResignBehavior: var  resignBehavior
autoHandle: var  autoHandle 
- (void) setResignBehavior: local  resignBehavior
autoHandle: local  autoHandle 
- (void) setResignBehavior: (tAudioManagerResignBehavior resignBehavior
autoHandle: (BOOL)  autoHandle 
- (void) setResignBehavior: var  resignBehavior
autoHandle: var  autoHandle 
- (void) setResignBehavior: local  resignBehavior
autoHandle: local  autoHandle 
+ (CDAudioManager *) sharedManager

Returns the shared singleton.

var sharedManager

Returns the shared singleton.

local sharedManager

Returns the shared singleton.

+ (CDAudioManager *) sharedManager

Returns the shared singleton.

var sharedManager

Returns the shared singleton.

local sharedManager

Returns the shared singleton.

+ (tAudioManagerState)
sharedManagerState
var sharedManagerState
local sharedManagerState
+ (tAudioManagerState)
sharedManagerState
var sharedManagerState
local sharedManagerState
- (void) stopBackgroundMusic

Stops playing the background music.

var stopBackgroundMusic

Stops playing the background music.

local stopBackgroundMusic

Stops playing the background music.

- (void) stopBackgroundMusic

Stops playing the background music.

var stopBackgroundMusic

Stops playing the background music.

local stopBackgroundMusic

Stops playing the background music.

Member Data Documentation

- (BOOL) _audioSessionActive
protected
var _audioSessionActive
protected
local _audioSessionActive
protected
- (NSString
*) _audioSessionCategory
protected
var _audioSessionCategory
protected
local _audioSessionCategory
protected
- (BOOL) _audioWasPlayingAtStartup
protected
var _audioWasPlayingAtStartup
protected
local _audioWasPlayingAtStartup
protected
- (BOOL) _interrupted
protected
var _interrupted
protected
local _interrupted
protected
- (BOOL) _isObservingAppEvents
protected
var _isObservingAppEvents
protected
local _isObservingAppEvents
protected
- (tAudioManagerMode) _mode
protected
var _mode
protected
local _mode
protected
- (BOOL) _mute
protected
var _mute
protected
local _mute
protected
- (tAudioManagerResignBehavior)
_resignBehavior
protected
var _resignBehavior
protected
local _resignBehavior
protected
- (BOOL) _resigned
protected
var _resigned
protected
local _resigned
protected
- (NSMutableArray
*) audioSourceChannels
protected
var audioSourceChannels
protected
local audioSourceChannels
protected
- (id)
backgroundMusicCompletionListener
protected
var
backgroundMusicCompletionListener
protected
local
backgroundMusicCompletionListener
protected
- (SEL)
backgroundMusicCompletionSelector
protected
var
backgroundMusicCompletionSelector
protected
local
backgroundMusicCompletionSelector
protected
- (BOOL) enabled_
protected
var enabled_
protected
local enabled_
protected

Property Documentation

- (CDLongAudioSource
*) backgroundMusic
readatomicassign
var backgroundMusic
readatomicassign
local backgroundMusic
readatomicassign
- (CDSoundEngine *) soundEngine
readatomicassign
var soundEngine
readatomicassign
local soundEngine
readatomicassign
- (BOOL) willPlayBackgroundMusic
readatomicassign
var willPlayBackgroundMusic
readatomicassign
local willPlayBackgroundMusic
readatomicassign

The documentation for this class was generated from the following file: