Skip to main content

CCSimpleAudioEngine

CCSimpleAudioEngine

CocosDenshion

Inheritance: System.Object

Constructors

CCSimpleAudioEngine()

CCSimpleAudioEngine()()

Properties

BackgroundMusicVolume(System.Single)
EffectsVolume(System.Single)
IsFading(System.Boolean)

Whether a background music fade is currently in progress.

SharedEngine(CocosDenshion.CCSimpleAudioEngine)

The singleton instance of this class. This property never throws.

SharedList(System.Collections.Generic.DictionarySystem.Int32,CocosDenshion.CCEffectPlayer)

The shared sound effect list. The key is the hashcode of the file path.

Methods

End()

End()()
Example

FadeBackgroundMusic(float, float)

FadeBackgroundMusic(float, float)(System.Single targetVolume, System.Single duration)

Fades the background music volume from the current level to a target level over a duration. Call UpdateFade(dt) each frame while fading.

Parameters:
targetVolume (System.Single) - Target volume (0.0 to 1.0).
duration (System.Single) - Fade duration in seconds.
Example

FullPath(string)

System.String FullPath(string)(System.String szPath)
Parameters:
szPath (System.String)
Returns:
System.String

IsBackgroundMusicPlaying()

System.Boolean IsBackgroundMusicPlaying()()
Returns:
System.Boolean
Example

PauseAllEffects()

PauseAllEffects()()

PauseBackgroundMusic()

PauseBackgroundMusic()()
Example

PauseEffect(int)

PauseEffect(int)(System.Int32 fxid)
Parameters:
fxid (System.Int32)

PlayBackgroundMusic(string)

PlayBackgroundMusic(string)(System.String pszFilePath)
Parameters:
pszFilePath (System.String)
Example

PlayBackgroundMusic(string, bool)

PlayBackgroundMusic(string, bool)(System.String pszFilePath, System.Boolean bLoop)
Parameters:
pszFilePath (System.String)
bLoop (System.Boolean)
Example

PlayEffect(int)

System.Int32 PlayEffect(int)(System.Int32 fxid)
Parameters:
fxid (System.Int32)
Returns:
System.Int32

PlayEffect(int, bool)

System.Int32 PlayEffect(int, bool)(System.Int32 fxid, System.Boolean bLoop)
Parameters:
fxid (System.Int32)
bLoop (System.Boolean)
Returns:
System.Int32

PlayEffect(string)

System.Int32 PlayEffect(string)(System.String pszFilePath)

Plays the given sound effect without looping.

Parameters:
pszFilePath (System.String) - The path to the sound effect
Returns:
System.Int32
Example

PlayEffect(string, bool)

System.Int32 PlayEffect(string, bool)(System.String pszFilePath, System.Boolean bLoop)

Play the sound effect with the given path and optionally set it to lopo.

Parameters:
pszFilePath (System.String) - The path to the sound effect file.
bLoop (System.Boolean) - True if the sound effect will play continuously, and false if it will play then stop.
Returns:
System.Int32
Example

PlayEffect(string, float)

System.Int32 PlayEffect(string, float)(System.String pszFilePath, System.Single volume)

Plays the sound effect at the given volume (0.0 to 1.0).

Parameters:
pszFilePath (System.String)
volume (System.Single)
Returns:
System.Int32
Example

PlayEffect(string, float, float)

System.Int32 PlayEffect(string, float, float)(System.String pszFilePath, System.Single volume, System.Single minInterval)

Plays the sound effect only if the minimum interval (in seconds) has elapsed since the last time this effect was played. Useful for preventing sound stacking.

Parameters:
pszFilePath (System.String)
volume (System.Single)
minInterval (System.Single)
Returns:
System.Int32
Example

PlayEffectHandled(string, float, bool)

CocosDenshion.CCSoundHandle PlayEffectHandled(string, float, bool)(System.String pszFilePath, System.Single volume, System.Boolean bLoop)

Plays a sound effect and returns a handle for per-instance control (volume, pan, pitch, stop, pause, resume). Returns null if audio hardware is unavailable or the effect cannot be played. The caller owns the returned handle and must call Dispose() when finished to release the underlying SoundEffectInstance.

Parameters:
pszFilePath (System.String) - Path to the sound effect file.
volume (System.Single) - Volume from 0.0 to 1.0.
bLoop (System.Boolean) - Whether to loop the sound.
Returns:
CocosDenshion.CCSoundHandle
Example

PreloadBackgroundMusic(string)

PreloadBackgroundMusic(string)(System.String pszFilePath)
Parameters:
pszFilePath (System.String)
Example

PreloadEffect(string)

PreloadEffect(string)(System.String pszFilePath)

Load the sound effect found with the given path. The sound effect is only loaded one time and the effect is cached as an instance of EffectPlayer.

Parameters:
pszFilePath (System.String)
Example

RestoreMediaState()

RestoreMediaState()()

Restore the media player's state to how it was prior to the game launch. You need to do this when the game terminates if you run music that clobbers the music that was playing before the game launched.

Example

ResumeAllEffects()

ResumeAllEffects()()

ResumeBackgroundMusic()

ResumeBackgroundMusic()()
Example

RewindBackgroundMusic()

RewindBackgroundMusic()()
Example

SaveMediaState()

SaveMediaState()()

Save the media player's current playback state.

Example

StopAllEffects()

StopAllEffects()()

StopAllLoopingEffects()

StopAllLoopingEffects()()

Stops all of the sound effects that are currently playing and looping.

Example

StopBackgroundMusic()

StopBackgroundMusic()()
Example

StopBackgroundMusic(bool)

StopBackgroundMusic(bool)(System.Boolean bReleaseData)
Parameters:
bReleaseData (System.Boolean)
Example

StopEffect(int)

StopEffect(int)(System.Int32 nSoundId)

Stops the sound effect with the given id.

Parameters:
nSoundId (System.Int32)
Example

UnloadEffect(string)

UnloadEffect(string)(System.String pszFilePath)
Parameters:
pszFilePath (System.String)
Example

Update(float)

Update(float)(System.Single dt)

Updates the background music fade. Call once per frame. Also updates throttle timers. Can be called unconditionally.

Parameters:
dt (System.Single)
Example

UpdateThrottleTimers(float)

UpdateThrottleTimers(float)(System.Single dt)

Call this each frame with the delta time to enable throttled playback via minInterval.

Parameters:
dt (System.Single)
Example

WillPlayBackgroundMusic()

System.Boolean WillPlayBackgroundMusic()()
Returns:
System.Boolean