IMineMusic.c
资源名称:brewmine3.rar [点击查看]
上传用户:yulinhuamu
上传日期:2009-12-26
资源大小:7287k
文件大小:2k
源码类别:
BREW编程
开发平台:
Visual C++
- #include "IMineMusic.h"
- //////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////
- static void IMINEMUSIC_CBStatus(void * pUser, AEESoundPlayerCmd eCBType, AEESoundPlayerStatus eSPStatus, uint32 dwParam);
- //////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////
- IMineMusic* IMINEMUSIC_CreateInstance(IShell* pIShell)
- {
- IMineMusic* pCtl=NULL;
- if(NULL==pIShell) return NULL;
- pCtl=MALLOCREC(IMineMusic);
- if(NULL==pCtl) return NULL;
- MEMSET(pCtl,0,sizeof(IMineMusic));
- pCtl->m_pIShell=pIShell;
- return pCtl;
- }
- boolean IMINEMUSIC_Release(IMineMusic* pCtl)
- {
- if(pCtl)
- {
- if(pCtl->m_pISoundPlayer)
- ISOUNDPLAYER_Release(pCtl->m_pISoundPlayer);
- FREEIF(pCtl);
- }
- return TRUE;
- }
- boolean IMINEMUSIC_Start(IMineMusic* pCtl,TMineMusicType type)
- {
- AEESoundPlayerInfo info;
- if(!pCtl) return FALSE;
- IMINEMUSIC_Stop(pCtl);
- if(SUCCESS!=ISHELL_CreateInstance(pCtl->m_pIShell, AEECLSID_SOUNDPLAYER, (void **)(&pCtl->m_pISoundPlayer)))
- return FALSE;
- ISOUNDPLAYER_RegisterNotify(pCtl->m_pISoundPlayer,IMINEMUSIC_CBStatus,pCtl);
- //get music name
- switch(type)
- {
- case MMT_FLASH:
- info.pData=(void*)"sound/flash.mp3";
- break;
- case MMT_START:
- info.pData=(void*)"sound/start.mid";
- break;
- case MMT_SUCCESS:
- info.pData=(void*)"sound/success.mid";
- break;
- case MMT_FAILURE:
- info.pData=(void*)"sound/failure.mid";
- break;
- default:
- return FALSE;
- }
- //start new music
- info.eInput=SDT_FILE;
- if(AEE_SUCCESS==ISOUNDPLAYER_SetInfo(pCtl->m_pISoundPlayer,&info))
- ISOUNDPLAYER_Play(pCtl->m_pISoundPlayer);
- return TRUE;
- }
- boolean IMINEMUSIC_Stop(IMineMusic* pCtl)
- {
- if(pCtl&&pCtl->m_pISoundPlayer)
- {
- ISOUNDPLAYER_Stop(pCtl->m_pISoundPlayer);
- ISOUNDPLAYER_Release(pCtl->m_pISoundPlayer);
- pCtl->m_pISoundPlayer=NULL;
- }
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////
- static void IMINEMUSIC_CBStatus(void * pUser, AEESoundPlayerCmd eCBType, AEESoundPlayerStatus eSPStatus, uint32 dwParam)
- {
- IMineMusic* pCtl=(IMineMusic*)pUser;
- if(pCtl&&(pCtl->m_pISoundPlayer)&&(AEE_SOUNDPLAYER_PLAY_CB==eCBType)&&(AEE_SOUNDPLAYER_DONE==eSPStatus))
- ISOUNDPLAYER_Play(pCtl->m_pISoundPlayer);
- }