IMedia | developer.brewmp.com IMedia | developer.brewmp.com

Developer

IMedia

Forums:

Hi,

I'm streaming qcp clips from the network. I'm using IMedia to play them (code below):

ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_MEDIAQCP, (void **)&pMe->m_pMedia);

AEEMediaData mediaData;
mediaData.clsData = MMD_BUFFER;
mediaData.pData = pQcpBuffer;
mediaData.dwSize = 25502;

IMEDIA_SetMediaData(pMe->m_pMedia, &mediaData);
IMEDIA_RegisterNotify(pMe->m_pMedia, mediaNotifyCallback, pMe);
IMEDIA_Play(pMe->m_pMedia);

Although not in the code above, I was checking the return value after each call and I noticed if I called IMEDIA_ReigsterNotify before IMEDIA_SetMediaData, I'd get a EBADSTATE return code.

Since I'm trying to start the next qcp I downloaded as soon as the previous one finished, I noticed that if I call IMEDIA_SetMediaData w/ the new qcp buffer in the MM_STATUS_DONE case in the IMEDIA_RegisterNotify callback, that I still receive an EBADSTATE. I tried explicitly calling IMEDIA_Stop as well first before calling SetMediaData with the new buffer. I also tried using a timer -- still EBADSTATE. It seems, that you can only call IMEDIA_SetMediaData once.

I tried the following code:

IMEDIA_SetMediaData(pMe->m_pMedia, &mediaData1);
IMEDIA_Play(pMe->m_pMedia);
IMEDIA_Stop(pMe->m_pMedia);
nReturn = IMEDIA_SetMediaData(pMe->m_pMedia, &mediaData2);
IMEDIA_Play(pMe->m_pMedia);

In the above code nReturn would always be EBADSTATE and the second Play call will execute successfully on the original Audio buffer. So my question is, how do I get IMEDIA to play my next song w/o me having to delete the object and reinstantiating each time.

Thanks.

Raj

Some update to above -- I tried circumventing the IMEDIA_SetMediaData call altogether by updating the AEEMediaData pData and dwSize to point to the new QCP buffer but still no luck. It appears that BREW copies the pointers from the AEEMediaData struct. So I tried overallocating the QCP buffer and MEMCPYing to it after the first QCP finishes playing and it works (ie the following could work although it makes no realistic sense):
IMEDIA_SetMediaData(pMe->m_pMedia, &mediaData1);
IMEDIA_RegisterNotify(pMe->m_pMedia, mediaNotifyCallback, pMe);
IMEDIA_Play(pMe->m_pMedia);
In callback on done event:
MEMCPY(pMe->m_pMedia, pMe->newAudioBuffer, 20000);
IMEDIA_Play(pMe->m_pMedia);
Although the above works, its terribly inefficient since I have to do a MEMCPY each time I want to play a new clip.
Raj

Some update to above -- I tried circumventing the IMEDIA_SetMediaData call altogether by updating the AEEMediaData pData and dwSize to point to the new QCP buffer but still no luck. It appears that BREW copies the pointers from the AEEMediaData struct. So I tried overallocating the QCP buffer and MEMCPYing to it after the first QCP finishes playing and it works (ie the following could work although it makes no realistic sense):
IMEDIA_SetMediaData(pMe->m_pMedia, &mediaData1);
IMEDIA_RegisterNotify(pMe->m_pMedia, mediaNotifyCallback, pMe);
IMEDIA_Play(pMe->m_pMedia);
In callback on done event:
MEMCPY(pMe->m_pMedia, pMe->newAudioBuffer, 20000);
IMEDIA_Play(pMe->m_pMedia);
Although the above works, its terribly inefficient since I have to do a MEMCPY each time I want to play a new clip.
Raj

It looks like MEMCPY is the approach if you want to loop your music to the next song etc, it also seems that BREW doesn't mind if you specify a AEEMediaData .dwSize as larger than the actual length of the QCP within your buffer as long as it's smaller than the size of your buffer. So this means you can overallocate your buffer and set the dwSize to the buffer size and then just MEMCPY varying length QCPs into AEEMediaData .pData
I haven't tried it on the phone yet though.
Raj

It looks like MEMCPY is the approach if you want to loop your music to the next song etc, it also seems that BREW doesn't mind if you specify a AEEMediaData .dwSize as larger than the actual length of the QCP within your buffer as long as it's smaller than the size of your buffer. So this means you can overallocate your buffer and set the dwSize to the buffer size and then just MEMCPY varying length QCPs into AEEMediaData .pData
I haven't tried it on the phone yet though.
Raj

i'm experiencing the same problem, when i call IMEDIA_SetMediaData i get the EBADSTATE even if my sound player is in Ready state.
Has anyone been able to change the sound a player plays witouth reconstructing it?

i'm experiencing the same problem, when i call IMEDIA_SetMediaData i get the EBADSTATE even if my sound player is in Ready state.
Has anyone been able to change the sound a player plays witouth reconstructing it?

Gugu wrote:i'm experiencing the same problem, when i call IMEDIA_SetMediaData i get the EBADSTATE even if my sound player is in Ready state.
Has anyone been able to change the sound a player plays witouth reconstructing it?
there seemd only two way:
1 release the meida instance and rebuit it
2 use new contents to fill in the buffer
and i have another question
when i want to loop songs,i use the first method above,but it don't work.
who can help me,thanks

Gugu wrote:i'm experiencing the same problem, when i call IMEDIA_SetMediaData i get the EBADSTATE even if my sound player is in Ready state.
Has anyone been able to change the sound a player plays witouth reconstructing it?
there seemd only two way:
1 release the meida instance and rebuit it
2 use new contents to fill in the buffer
and i have another question
when i want to loop songs,i use the first method above,but it don't work.
who can help me,thanks

Using IMEDIA_SetMEdiaParm() with MM_PARM_PLAY_REPEAT didnt work for me, at least on the devices i tried it on.
So when i want a sound to loop i raise a flag, and when i get MM_STATUS_DONE in the callback i call play again if that flag is raised, works fine for me.

Using IMEDIA_SetMEdiaParm() with MM_PARM_PLAY_REPEAT didnt work for me, at least on the devices i tried it on.
So when i want a sound to loop i raise a flag, and when i get MM_STATUS_DONE in the callback i call play again if that flag is raised, works fine for me.

Gugu wrote:Using IMEDIA_SetMEdiaParm() with MM_PARM_PLAY_REPEAT didnt work for me, at least on the devices i tried it on.
So when i want a sound to loop i raise a flag, and when i get MM_STATUS_DONE in the callback i call play again if that flag is raised, works fine for me.
it do work,i do this also
but this method do not work if i want to loop different sounds
do any one know how to loop different songs?
thanks

Gugu wrote:Using IMEDIA_SetMEdiaParm() with MM_PARM_PLAY_REPEAT didnt work for me, at least on the devices i tried it on.
So when i want a sound to loop i raise a flag, and when i get MM_STATUS_DONE in the callback i call play again if that flag is raised, works fine for me.
it do work,i do this also
but this method do not work if i want to loop different sounds
do any one know how to loop different songs?
thanks

zzdsp wrote:it do work,i do this also
but this method do not work if i want to loop different sounds
do any one know how to loop different songs?
thanks
Does anyone have solution?
Although the problem already existed one year ago... :eek:
FireStoke

zzdsp wrote:it do work,i do this also
but this method do not work if i want to loop different sounds
do any one know how to loop different songs?
thanks
Does anyone have solution?
Although the problem already existed one year ago... :eek:
FireStoke

I have succesfully played a SDP file by using the MMD_FILE_NAME
but when I tried to store the contents of the .sdp file into a const char* const buffer="-----------------";
and pass it as a MMD_BUFFER
and pass the buffer and STRLEN(buffer) for pData and dwSize,, it does not work ,,
Can anyone tell me what am I doing wrong,
Thanks in advance
crazycoder

I have succesfully played a SDP file by using the MMD_FILE_NAME
but when I tried to store the contents of the .sdp file into a const char* const buffer="-----------------";
and pass it as a MMD_BUFFER
and pass the buffer and STRLEN(buffer) for pData and dwSize,, it does not work ,,
Can anyone tell me what am I doing wrong,
Thanks in advance
crazycoder

Hi,
I suggest calling the SetMedia only once, and then, when u get a new file, copy that to the MEdia data struct and seek the pointer to the begining and then Play..
So the trick is, when u get the FIRST buffer, set the Media data with that buffer, but, then onwards, copy the buffer and reset the seek pointer to begining.. Hope this will do the trick..
Cheers
CoolB..

Hi,
I suggest calling the SetMedia only once, and then, when u get a new file, copy that to the MEdia data struct and seek the pointer to the begining and then Play..
So the trick is, when u get the FIRST buffer, set the Media data with that buffer, but, then onwards, copy the buffer and reset the seek pointer to begining.. Hope this will do the trick..
Cheers
CoolB..