Original Work, reprinted, please mark:
Android: on android, CocosDenshion supports the audio format that corresponds to the format supported by android. media. MediaPlayer. IOS: The formats supported by CocosDenshion in the Cocos2d-x on IOS are the same as those supported in the Cocos2d-iphone, and mp3, caf is the recommended format. Windows:. mid,. wav are supported. Note that mp3 is not supported. Marmalade: mp3
# Include "SimpleAudioEngine. h" using namespace CocosDenshion; // if this step is missing, SimpleAudioEngine cannot be found.
CocosDenshion::SimpleAudioEngine
SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic("sound/game_music.mp3");
SimpleAudioEngine: sharedEngine ()-> playBackgroundMusic ("sound/game_musicloud", true); // start playing background music. true indicates loop SimpleAudioEngine: sharedEngine () -> stopBackgroundMusic (); // stop the background music. This is a default parameter function. Passing a parameter indicates whether to release the music file SimpleAudioEngine: sharedEngine ()-> pauseBackgroundMusic (); // pause background music SimpleAudioEngine: sharedEngine ()-> rewindBackgroundMusic (); // call background music SimpleAudioEngine: sharedEngine ()-> isBackgroundMusicPlaying () // return a Boolean parameter indicating whether the background music SimpleAudioEngine: sharedEngine ()-> setBackgroundMusicVolume (0.5) is being played. // set the volume to 0.0-1.0
SimpleAudioEngine::sharedEngine()->preloadEffect("sound/bullet.mp3");
SimpleAudioEngine: sharedEngine ()-> playEffect ("sound/bulletask", false); // start playing background sound effects. false indicates no loop SimpleAudioEngine: sharedEngine () -> stopEffect (m_nSoundId); // you can choose to stop a sound effect independently. The value is SimpleAudioEngine: sharedEngine ()-> stopAllEffects () returned by playEffect (); // stop all sound effects SimpleAudioEngine: sharedEngine ()-> pauseEffect (m_nSoundId); // pause a single sound effect SimpleAudioEngine: sharedEngine ()-> resumeEffect (m_nSoundId ); // restart the sound effects SimpleAudioEngine: sharedEngine ()-> pauseAllEffects (); // pause all sound effects SimpleAudioEngine: sharedEngine ()-> resumeAllEffects (); // re-start all sound effects SimpleAudioEngine: sharedEngine ()-> setEffectsVolume (0.5); // set the sound volume 0.0-1.0 SimpleAudioEngine: sharedEngine () -> unloadEffect ("sound/bulletask"); // uninstall the sound effect.
static EffectList s_List;
void SimpleAudioEngine::end()
void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath){}
void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop){ if (! pszFilePath) { return; } sharedMusic().Open(_FullPath(pszFilePath), _Hash(pszFilePath)); sharedMusic().Play((bLoop) ? -1 : 1);}