Hello, I am trying to acomplish this thematic of playing a MP3 sound file that is a resource in memory. I'm really not interested about
playing it from a file because that I already did. I was looking some codes over the net but some of them refer to using some libraries like BASS or FMOD or similar.. I was trying to do this using the normal Windows API, but it seems not posible or I don't know it
If anyone here knows, can kindly tell me how to do this ?
I show you what I was trying the latests...
see this link
https://docs.microsoft.com/en-us/win...orm-audio-file
I modified that function, after reading some information on it. This information:
https://docs.microsoft.com/en-us/win...ectedfrom=MSDN
https://docs.microsoft.com/en-us/win...ave-open-parms
https://docs.microsoft.com/en-us/win...media/mci-open
and more
http://wisdom.sakura.ne.jp/system/winapi/media/mm3.html
http://www.frolov-lib.ru/books/bsp/v15/ch2_3.htm
https://wenku.baidu.com/view/3f0a861...e7cd13782.html
https://dixq.net/forum/viewtopic.php?t=19986
http://drang.s4.xrea.com/program/lib/myMPlayer.pas
http://www.st.sakura.ne.jp/~higashi/c_lan/mciload.txt
it seems that developers of this "seemed" to have left a hidden way of playing the mp3 from a buffer in memory, or maybe is not like this,
but there is a flag called MCI_WAVE_OPEN_BUFFER for using when calling mciSendCommand with MCI_OPEN , and it really isn't working for me
these structures are for reference
I was using this function like this
help?
playing it from a file because that I already did. I was looking some codes over the net but some of them refer to using some libraries like BASS or FMOD or similar.. I was trying to do this using the normal Windows API, but it seems not posible or I don't know it
If anyone here knows, can kindly tell me how to do this ?
I show you what I was trying the latests...
see this link
https://docs.microsoft.com/en-us/win...orm-audio-file
I modified that function, after reading some information on it. This information:
https://docs.microsoft.com/en-us/win...ectedfrom=MSDN
https://docs.microsoft.com/en-us/win...ave-open-parms
https://docs.microsoft.com/en-us/win...media/mci-open
and more
http://wisdom.sakura.ne.jp/system/winapi/media/mm3.html
http://www.frolov-lib.ru/books/bsp/v15/ch2_3.htm
https://wenku.baidu.com/view/3f0a861...e7cd13782.html
https://dixq.net/forum/viewtopic.php?t=19986
http://drang.s4.xrea.com/program/lib/myMPlayer.pas
http://www.st.sakura.ne.jp/~higashi/c_lan/mciload.txt
it seems that developers of this "seemed" to have left a hidden way of playing the mp3 from a buffer in memory, or maybe is not like this,
but there is a flag called MCI_WAVE_OPEN_BUFFER for using when calling mciSendCommand with MCI_OPEN , and it really isn't working for me
Code:
/*
typedef struct tagMCI_OPEN_PARMSW {
DWORD dwCallback;
MCIDEVICEID wDeviceID;
LPCWSTR lpstrDeviceType;
LPCWSTR lpstrElementName;
LPCWSTR lpstrAlias;
} MCI_OPEN_PARMSW, *PMCI_OPEN_PARMSW, *LPMCI_OPEN_PARMSW;*/
/*
typedef struct tagMCI_WAVE_OPEN_PARMSW {
DWORD dwCallback;
MCIDEVICEID wDeviceID;
LPCWSTR lpstrDeviceType;
LPCWSTR lpstrElementName;
LPCWSTR lpstrAlias;
DWORD dwBufferSeconds;
} MCI_WAVE_OPEN_PARMSW, *PMCI_WAVE_OPEN_PARMSW, *LPMCI_WAVE_OPEN_PARMSW;*/
typedef struct tagMCI_WAVE_OPEN_PARMS2 {
DWORD dwCallback;
UINT wDeviceID;
UINT wReserved0;
LPCWSTR lpstrDeviceType;
LPCWSTR lpstrElementName;
LPCWSTR lpstrAlias;
DWORD dwBufferSeconds;
} MCI_WAVE_OPEN_PARMS2;
//typedef MCI_WAVE_OPEN_PARMS FAR * LPMCI_WAVE_OPEN_PARMS;
Code:
DWORD playWAVEFile(HWND hWndNotify, LPWSTR lpszWAVEFileName, unsigned int BufLen)
{
UINT wDeviceID = 0;
DWORD dwReturn = 0;
// MCI_OPEN_PARMS mciOpenParms;
MCI_WAVE_OPEN_PARMS2 mciOpenParms;
MCI_PLAY_PARMS mciPlayParms;
// Open the device by specifying the device and filename.
// MCI will choose a device capable of playing the specified file.
mciOpenParms.dwCallback=0L;
mciOpenParms.wDeviceID=0;
// mciOpenParms.lpstrDeviceType = L"waveaudio";
mciOpenParms.lpstrDeviceType = (unsigned short*)MCI_DEVTYPE_WAVEFORM_AUDIO;
mciOpenParms.lpstrElementName = L"";
mciOpenParms.dwBufferSeconds = BufLen;
mciOpenParms.wReserved0=(UINT)lpszWAVEFileName;
dwReturn = mciSendCommand(0, MCI_OPEN,
// MCI_NOTIFY|
MCI_WAVE_OPEN_BUFFER
|MCI_OPEN_TYPE
|MCI_OPEN_TYPE_ID
// | MCI_OPEN_ELEMENT
//| MCI_WAIT
// |MCI_OPEN_SHAREABLE
,
(DWORD)(LPVOID) &mciOpenParms);
if (dwReturn)
{
MessageBoxA(0,"RETURN BAD 1",0,0);
// Failed to open device. Don't close it; just return error.
return (dwReturn);
}
// The device opened successfully; get the device ID.
wDeviceID = mciOpenParms.wDeviceID;
// Begin playback. The window procedure function for the parent
// window will be notified with an MM_MCINOTIFY message when
// playback is complete. At this time, the window procedure closes
// the device.
mciPlayParms.dwCallback = (DWORD) hWndNotify;
dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_NOTIFY,
(DWORD)(LPVOID) &mciPlayParms);
if (dwReturn)
{
MessageBoxA(0,"RETURN BAD 2",0,0);
mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
return (dwReturn);
}
return (0L);
}
I was using this function like this
Code:
unsigned int BLen = ResourceMP3ToBuffer(IDR_MP31);// mp3 as resource id
if(BLen)
{
if(bMP31)// buffer containing resource
{
DWORD dwret = playWAVEFile(hDlg, (unsigned short*)bMP31, BLen);
}
else
{
MessageBoxA(0,"buf not loaded",0,0);
}
}
else
{
MessageBoxA(0,"no size",0,0);
}