Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi,

I want to play a mid file using bmp . Can anyone suggest how to fill AEEMediaData structure to be used in IMEDIAUTIL_CreateMedia();

i tried this code, but with no success:

IMedia *ppm = NULL;
IMediaUtil * pIMediaUtil = NULL;
AEEMediaData mediaData;
int err;

ISHELL_CreateInstance(pMe->pIShell,AEECLSID_MEDIAUTIL,&pIMediaUtil);
mediaData.clsData = MMD_FILE_NAME;
mediaData.pData = (AECHAR*)L"fs:/shared/in1.mid";
mediaData.dwSize = 1000;

err = IMEDIAUTIL_CreateMedia(pIMediaUtil,&mediaData,&ppm);

Can anyone suggest what am i doing wrong?"fs:/shared/in1.mid" is the location of my mid file.
Thanks in advance

Hi annu,
Here are some recommendations after looking at your pasted source.
(1) mediaData.pData should be a char* and not an AECHAR*.
(2) Set mediaData.dwSize to something like (uint32) STRLEN( filePath).
Let me know if this works.
Thanks,
Anand

Hi annu,
Here are some recommendations after looking at your pasted source.
(1) mediaData.pData should be a char* and not an AECHAR*.
(2) Set mediaData.dwSize to something like (uint32) STRLEN( filePath).
Let me know if this works.
Thanks,
Anand

Hi Anandus,
Thanks for your reply. Now the AEEMediaData structure is getting filled correctly and IMedia object is getting created too, but it seems like IMEDIA_Play() is not working because even though there is no crashing, i still can't hear the song being played in the emulator. Do i need to do something else?? Please have a look at the code below and let me know:
AECHAR szBuf[64] = {0};
int nStrLen = 0;
IMediaUtil *pMediaUtil = NULL;
IMedia *pIMediaObject= NULL;
AEEMediaData sMediaData;
char szFilename[30] = "fs:/shared/09 - Shattered.mp3";
ISHELL_CreateInstance(pMe->pIShell, AEECLSID_MEDIAUTIL, (void **)&pMediaUtil);
if(!pMediaUtil)
{
//Error....

sMediaData.clsData = MMD_FILE_NAME;
sMediaData.pData = (void *)& szFilename;
sMediaData.dwSize = (uint32) STRLEN(szFilename);
IMEDIAUTIL_CreateMedia(pMediaUtil, &sMediaData, &pIMediaObject);
if(!pIMediaObject)
{
//Error....

IMEDIAUTIL_Release(pMediaUtil);
IMEDIA_Play(pIMediaObject);
IMEDIA_RegisterNotify(pIMediaObject, IMediaEventHandler,(void *) pMe);
IMEDIA_GetTotalTime(pIMediaObject);
My callback handler fumnction code is:
void IMediaEventHandler(void *pUser, AEEMediaCmdNotify *pCmdNotify)
{
MediaSong *pMe = (MediaSong*)pUser;
AEERect sRect;
switch(pCmdNotify->nCmd)
{
case MM_CMD_GETTOTALTIME:
if(pCmdNotify->nStatus == MM_STATUS_DONE)
{
pMe->dwTotalMediaTime = (int)pCmdNotify->pCmdData;
if( SUCCESS != IMEDIA_Play(pCmdNotify->pIMedia) )
{
//Set a timer to attempt the play later
}
}
break;
case MM_CMD_PLAY:
switch(pCmdNotify->nStatus)
{
case MM_STATUS_START:
//Change UI to reflect play status
break;
case MM_STATUS_DONE:
//Change UI to reflect stop status
break;
case MM_STATUS_TICK_UPDATE:
//Advance your time counter here
break;
}
break;
}

Thanks in advance

Hi Anandus,
Thanks for your reply. Now the AEEMediaData structure is getting filled correctly and IMedia object is getting created too, but it seems like IMEDIA_Play() is not working because even though there is no crashing, i still can't hear the song being played in the emulator. Do i need to do something else?? Please have a look at the code below and let me know:
AECHAR szBuf[64] = {0};
int nStrLen = 0;
IMediaUtil *pMediaUtil = NULL;
IMedia *pIMediaObject= NULL;
AEEMediaData sMediaData;
char szFilename[30] = "fs:/shared/09 - Shattered.mp3";
ISHELL_CreateInstance(pMe->pIShell, AEECLSID_MEDIAUTIL, (void **)&pMediaUtil);
if(!pMediaUtil)
{
//Error....

sMediaData.clsData = MMD_FILE_NAME;
sMediaData.pData = (void *)& szFilename;
sMediaData.dwSize = (uint32) STRLEN(szFilename);
IMEDIAUTIL_CreateMedia(pMediaUtil, &sMediaData, &pIMediaObject);
if(!pIMediaObject)
{
//Error....

IMEDIAUTIL_Release(pMediaUtil);
IMEDIA_Play(pIMediaObject);
IMEDIA_RegisterNotify(pIMediaObject, IMediaEventHandler,(void *) pMe);
IMEDIA_GetTotalTime(pIMediaObject);
My callback handler fumnction code is:
void IMediaEventHandler(void *pUser, AEEMediaCmdNotify *pCmdNotify)
{
MediaSong *pMe = (MediaSong*)pUser;
AEERect sRect;
switch(pCmdNotify->nCmd)
{
case MM_CMD_GETTOTALTIME:
if(pCmdNotify->nStatus == MM_STATUS_DONE)
{
pMe->dwTotalMediaTime = (int)pCmdNotify->pCmdData;
if( SUCCESS != IMEDIA_Play(pCmdNotify->pIMedia) )
{
//Set a timer to attempt the play later
}
}
break;
case MM_CMD_PLAY:
switch(pCmdNotify->nStatus)
{
case MM_STATUS_START:
//Change UI to reflect play status
break;
case MM_STATUS_DONE:
//Change UI to reflect stop status
break;
case MM_STATUS_TICK_UPDATE:
//Advance your time counter here
break;
}
break;
}

Thanks in advance