Class cc.WebAudioEngine
- Defined in: SimpleAudioEngine.js
- Extends cc.AudioEngine
Constructor Attributes | Constructor Name and Description |
---|---|
The Audio Engine implementation via Web Audio API.
|
Method Summary
Class Detail
cc.WebAudioEngine()
The Audio Engine implementation via Web Audio API.
Method Detail
-
ctor()Constructor
-
{Number} getEffectsVolume()The volume of the effects max value is 1.0,the min value is 0.0 .
//example var effectVolume = cc.AudioEngine.getInstance().getEffectsVolume();
- Returns:
- {Number}
-
{Number} getMusicVolume()The volume of the music max value is 1.0,the min value is 0.0 .
//example var volume = cc.AudioEngine.getInstance().getMusicVolume();
- Returns:
- {Number}
-
{Boolean} init()Initialization
- Returns:
- {Boolean}
-
{Boolean} isFormatSupported(ext)search in this._supportedFormat if ext is there
- Parameters:
- {String} ext
- Returns:
- {Boolean}
-
{Boolean} isMusicPlaying()Whether it is playing any music
//example if (cc.AudioEngine.getInstance().isMusicPlaying()) { cc.log("music is playing"); } else { cc.log("music is not playing"); }
- Returns:
- {Boolean} If is playing return true,or return false.
-
pauseAllEffects()Pause all playing sound effect.
//example cc.AudioEngine.getInstance().pauseAllEffects();
-
pauseEffect(audioID)Pause playing sound effect.
//example cc.AudioEngine.getInstance().pauseEffect(audioID);
- Parameters:
- {Number} audioID
- The return value of function playEffect.
-
pauseMusic()Pause playing music.
//example cc.AudioEngine.getInstance().pauseMusic();
-
playEffect(path, loop)Play sound effect.
//example cc.AudioEngine.getInstance().playEffect(path);
- Parameters:
- {String} path
- The path of the sound effect with filename extension.
- {Boolean} loop
- Whether to loop the effect playing, default value is false
-
playMusic(path, loop)Play music.
//example cc.AudioEngine.getInstance().playMusic(path, false);
- Parameters:
- {String} path
- The path of the music file without filename extension.
- {Boolean} loop
- Whether the music loop or not.
-
preloadEffect(path)Preload effect resource.
- Parameters:
- {String} path
-
preloadMusic(path)Preload music resource.
- Parameters:
- {String} path
-
preloadSound(path)Preload music resource.
This method is called when cc.Loader preload resources.- Parameters:
- {String} path
- The path of the music file with filename extension.
-
resumeAllEffects()Resume all playing sound effect
//example cc.AudioEngine.getInstance().resumeAllEffects();
-
resumeEffect(audioID)Resume playing sound effect.
//example cc.AudioEngine.getInstance().resumeEffect(audioID);
- Parameters:
- {Number} audioID
- The return value of function playEffect.
-
resumeMusic()Resume playing music.
//example cc.AudioEngine.getInstance().resumeMusic();
-
rewindMusic()Rewind playing music.
//example cc.AudioEngine.getInstance().rewindMusic();
-
setEffectsVolume(volume)Set the volume of sound effects.
//example cc.AudioEngine.getInstance().setEffectsVolume(0.5);
- Parameters:
- {Number} volume
- Volume must be in 0.0~1.0 .
-
setMusicVolume(volume)Set the volume of music.
//example cc.AudioEngine.getInstance().setMusicVolume(0.5);
- Parameters:
- {Number} volume
- Volume must be in 0.0~1.0 .
-
stopAllEffects()Stop all playing sound effects.
//example cc.AudioEngine.getInstance().stopAllEffects();
-
stopEffect(audioID)Stop playing sound effect.
//example cc.AudioEngine.getInstance().stopEffect(audioID);
- Parameters:
- {Number} audioID
- The return value of function playEffect.
-
stopMusic(releaseData)Stop playing music.
//example cc.AudioEngine.getInstance().stopMusic();
- Parameters:
- {Boolean} releaseData
- If release the music data or not.As default value is false.
-
unloadEffect(path)Unload the preloaded effect from internal buffer
//example cc.AudioEngine.getInstance().unloadEffect(EFFECT_FILE);
- Parameters:
- {String} path