www.pudn.com > bmbrsrc > BomberMidi.c
MCIDEVICEID gDeviceID = -1;
int Playing = 0;
void PlayMidi (char *FileName)
{
char PathName [2048];
MCI_OPEN_PARMS OpenStructure;
MCI_PLAY_PARMS PlayStructure;
if (gDeviceID != -1) {
mciSendCommand (gDeviceID, MCI_STOP, 0, 0);
mciSendCommand (gDeviceID, MCI_CLOSE, 0, 0);
gDeviceID = -1;
}
//Append full path to filename
strcpy (PathName, StartDir);
strcat (PathName, FileName);
OpenStructure.lpstrDeviceType = "sequencer";
OpenStructure.lpstrElementName = PathName;
mciSendCommand (0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&OpenStructure);
gDeviceID = OpenStructure.wDeviceID;
Playing = -1;
PlayStructure.dwCallback = (DWORD)WindowHandle;
mciSendCommand (gDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&PlayStructure);
}
void StopMidi ()
{
if (gDeviceID != -1) {
mciSendCommand (gDeviceID, MCI_STOP, 0, 0);
mciSendCommand (gDeviceID, MCI_CLOSE, 0, 0);
gDeviceID = -1;
Playing = 0;
}
}
void UnloadMidi ()
{
if (gDeviceID != -1) {
mciSendCommand (gDeviceID, MCI_STOP, 0, 0);
mciSendCommand (gDeviceID, MCI_CLOSE, 0, 0);
}
}