Click to See Complete Forum and Search --> : Playing an MP3 from a buffer


riscutiavlad
October 24th, 2006, 12:49 AM
Is it possible to play an MP3 from a buffer using MCI commands?

I know it can be played from a file on disk by specifing a file name in the lpstrElementName member of MCI_OPEN_PARMS but I need to play it directly from a buffer. Our application loads all its resources from a DLL and we don't want to create temporary files on disk at runtime.

Thank you.

UnfitElf
October 26th, 2006, 05:06 AM
I was intrested in this some time ago also, and i did find somthing. Tho from memory it wasnt worth the effort for me and i forgot about it. I have no idea where i found it now :( but Ill keep looking :)

Marc G
October 26th, 2006, 05:23 AM
Maybe the following article can help you (I'm not sure if it works with MP3 files):
How To Use MCI to Play AVI/WAVE Files from Memory (http://support.microsoft.com/kb/155360)

riscutiavlad
November 7th, 2006, 06:29 AM
Thank you for the link, I tried but I still can't make it work.

From what I understood only waveaudio and avivideo can be played from memory. I wrote a callback method to open/read/seek on a buffer and installed it. I read a file into that buffer and here is the funny thing: when I read a .wav file and play it like this:

mmioInstallIOProc(mmioFOURCC('M', 'E', 'Y', ' '), (LPMMIOPROC)IOProc, MMIO_INSTALLPROC | MMIO_GLOBALPROC);
mciSendString("open test.MEY+ type waveaudio alias test", 0, 0, 0);
mciSendString("play test", NULL, 0, 0);

it works fine, when I load an .mp3 file and play it with

mmioInstallIOProc(mmioFOURCC('M', 'E', 'Y', ' '), (LPMMIOPROC)IOProc, MMIO_INSTALLPROC | MMIO_GLOBALPROC);
mciSendString("open test.MEY+ type mpegvideo alias test", 0, 0, 0);
mciSendString("play test", NULL, 0, 0);

it doesn't work and I get a "Cannot find the specified file" error. Does anyone know any workaround for this? Or maybe another approach?

Marc G
November 7th, 2006, 07:54 AM
I've never done it myself so I don't know why it is not working.
Do you have to use MCI?
Maybe you can use another audio library, for example fmod (http://www.fmod.org)? Note, I have used fmod before but not for streaming from memory, so I'm not 100% sure if it works, but I think it should work. It's worth a try.

riscutiavlad
November 8th, 2006, 01:25 AM
I see fmod has a dll which must be shipped with the application, meaning I can't use it (it's not up to me).