Example #1
0
void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop)
{
    if (! pszFilePath)
    {
        return;
    }

    sharedMusic().Open(_FullPath(pszFilePath).c_str(), _Hash(pszFilePath));
    sharedMusic().Play((bLoop) ? -1 : 1);
}
void SimpleAudioEngine::preloadEffect(const char* pszFilePath)
{
	int nRet = 0;
	do 
	{
		BREAK_IF(! pszFilePath);

		nRet = _Hash(pszFilePath);

		BREAK_IF(s_List.end() != s_List.find(nRet));

		s_List.insert(Effect(nRet, MciPlayer()));
		MciPlayer& player = s_List[nRet];
		player.Open(_FullPath(pszFilePath), nRet);

		BREAK_IF(nRet == player.GetSoundID());

		s_List.erase(nRet);
		nRet = 0;
	} while (0);
}
Example #3
0
void SimpleAudioEngine::preloadEffect(const char* pszFilePath)
{
    int nRet = 0;
    do 
    {
        BREAK_IF(! pszFilePath);

        nRet = _Hash(pszFilePath);

        BREAK_IF(sharedList().end() != sharedList().find(nRet));

        sharedList().insert(Effect(nRet, new MciPlayer()));
        MciPlayer * pPlayer = sharedList()[nRet];
        pPlayer->Open(_FullPath(pszFilePath), nRet);

        BREAK_IF(nRet == pPlayer->GetSoundID());

        sharedList().erase(nRet);
        nRet = 0;
    } while (0);
}