bombermidi.c

来自「一个炸弹人游戏的源代码(win32 application)」· C语言 代码 · 共 47 行

C
47
字号
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);
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?