当前位置: 代码迷 >> Brew >> 如何实现背景音乐循环播放
  详细解决方案

如何实现背景音乐循环播放

热度:8074   发布时间:2013-02-26 00:00:00.0
怎么实现背景音乐循环播放?
我的做法是:
static void IMediamethod(test* pMe)
{
AEEMediaData mediaData;
ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_MEDIAQCP, (void **)&pMe->m_pMedia);

mediaData.clsData = MMD_FILE_NAME;
mediaData.pData = "music.mid";
mediaData.dwSize = 0;
IMEDIA_SetMediaData(pMe->m_pMedia, &mediaData);
}
void Music_Start(test *pMe)
{
if (NULL!=pMe->m_pMedia)
{
IMEDIA_SetMediaParm(pMe->m_pMedia,MM_PARM_PLAY_REPEAT,0,0);
IMEDIA_Play(pMe->m_pMedia);
}
}

这种情况模拟器上可以实现循环播放,但是在真机上面不可以,

我换成注册回调:
static void MediaNotify(void *pUser,AEEMediaCmdNotify *pCmdNotify)
{
if(((test*)pUser)->isMusic)
{
if( pCmdNotify->nCmd == MM_CMD_PLAY)
{
if(pCmdNotify->nStatus == MM_STATUS_DONE)

IMEDIA_Play(((test*)pUser)->m_pMedia);
}
}
}
}

static void IMediamethod(test* pMe)
{
AEEMediaData mediaData;
ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_MEDIAQCP, (void **)&pMe->m_pMedia);

mediaData.clsData = MMD_FILE_NAME;
mediaData.pData = "music.mid";
mediaData.dwSize = 0;
IMEDIA_SetMediaData(pMe->m_pMedia, &mediaData);
IMEDIA_RegisterNotify(pMe->m_pMedia,MediaNotify,(void *)pMe);
}

这样的话,模拟器循环倒是循环,但每按一下键,他就从头开始播放了,真机上没测,
IMediamethod()是在InitAppData函数里调用的,
那位高手给指点一下该怎么做,不知道用ISoundPlayer 接口怎么样,最好有真机上实现的实例,
先行谢过!

------解决方案--------------------------------------------------------
大哥,你真牛逼啊,