I'm trying to play a midi file using MCISendCommand but I keep getting a DWORD error code 275 (File Not found). I have since placed the relevant code inside a fstream open call which DOES find the file. I then close the file to allow the MCISendCommand code to access it but it still cannot find the file.
Here is the relevant code:
fstream f;
f.open(szMIDIFileName);
if(f.is_open())
// Then the file exists
{
f.close();
// See if the MIDI player needs to be opened
if (m_uiMIDIPlayerID == 0)
{
// Open the MIDI player by specifying the device and filename
MCI_OPEN_PARMS mciOpenParms;
mciOpenParms.lpstrDeviceType = "sequencer";
mciOpenParms.lpstrElementName = szMIDIFileName; //The name of the file passed in as a param
if (mciSendCommand(NULL, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,
(DWORD_PTR)&mciOpenParms) == 0)
// Get the ID for the MIDI player
m_uiMIDIPlayerID = mciOpenParms.wDeviceID;
else
// There was a problem, so just return
// This is where I keep ending up in my code with DWORD error 275
return;
}
}
I should also mention that this code works in a sample project from a textbook of mine "Beginning Game Programming" by Michael Morrison. As far as I can tell all project properties are identical. For some reason, however, the code does not work for me in my own project, even though I have since copy/pasted every single line of code over from the sample project (there is not that much, 3/5 small classes).
Two things you might want to try:
In other words, let the system choose for you the device type, rather than setting it to "Sequencer".