KDvoid SimpleAudioEngine::preloadBackgroundMusic ( const KDchar* szFilePath )
{
	if ( !szFilePath )
	{
		return;
	}

	std::string  sPath = FileUtils::getInstance ( )->fullPathForFilename ( szFilePath );
	KDuint		 uID   = _Hash ( sPath.c_str ( ) );

	this->stopBackgroundMusic ( true );

	SoundList::iterator it = l_aMusicList.find ( uID );
	if ( it == l_aMusicList.end ( ) )
	{
		XMSound*  pSound = xmSoundOpen ( sPath.c_str ( ), XM_SOUND_NORMAL );

		if ( pSound )
		{
			xmSoundSetCallback ( pSound, background_callBack );

			l_aMusicList.insert ( Sound ( uID, pSound ) );			
		}
	}
}
KDuint SimpleAudioEngine::preloadEffect(const KDchar* szFilePath, const KDchar* szKey)
{
	std::string  sPath = FileUtils::getInstance()->fullPathForFilename(szFilePath);
	KDuint		   uID = _Hash(szKey ? szKey : sPath.c_str());

	SoundList::iterator it = l_aEffectList.find(uID);
	if (it == l_aEffectList.end())
	{
		XMSound*  pSound = xmSoundOpen(sPath.c_str(), XM_SOUND_EFFECT);

		if (pSound)
		{
			l_aEffectList.insert(Sound(uID, pSound));
		}
	}

	return uID;
}
Exemple #3
0
 // Add a new sound to the list
 void addNew(ManagedSound* snd)
 {
   list.insert(snd);
 }