Home
Tutorials
Code Snippets
Code Samples
Downloads
Links

The Blog
Our Projects
About
Contact

::Add RageStorm to Favorites!::

The Blog | Our Projects | Guest Book | About | Contact

 
Tutorial - MCI
Author:Arkon
Category:Win32API
Uploaded at:29-May-03
Views:9930
The MCI which stands for Media Control Interface is very easy to use.
In this tutorial I'll show you how to load a .MID and play it.
Most of the MCI calls are done through the mciSendCommand(...) function,
whenever we use this function we need an ID for the device player,
so if we want to stop the playing for instance we need to pass the
device ID that plays the MIDI and tell it to stop...So we'll save this ID.
Let's start then:
We tell the MCI to load a MIDI off a file and to start playing(once).
MCI_OPEN_PARMS mciOpenParms;
// "sequencer" - means we want to play a MIDI.
mciOpenParms.lpstrDeviceType = "sequencer";
// The MIDI file name.
mciOpenParms.lpstrElementName = strFileName;
// We open the MIDI for playing.
mciSendCommand(NULL, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, 
               (DWORD)&mciOpenParms);
MIDI_Device = mciOpenParms.wDeviceID;
// Getting the Device ID which will play the MIDI.

MCI_PLAY_PARMS mciPlayParms;
// This struct is for the playing parameters we want. 
// We pass the handle of the window because when the MIDI
// will be finished playing, it will notify us (then we may
// play it again[looped]).
mciPlayParms.dwCallback = (DWORD)hWnd;
mciSendCommand(MIDI_Device, MCI_PLAY, MCI_NOTIFY, (DWORD)&mciPlayParms);

OK that was it for loading and playing, MCI does life easy, HUH? :)
Now let's see how to close the device player(this will free the MIDI too):
// Closing the MIDI.
if (MIDI_Device) mciSendCommand(MIDI_Device, MCI_CLOSE, 0, NULL);
MIDI_Device = NULL;

Well you gotta see the source code, it has a REAL nice GUI,
and you may learn how to use dialog boxes....Check it out!

Source Code:
Visual C++ 6 - MIDI.zip

User Contributed Comments(1)
 [1] Peter | 2007-08-24 12:30:32

Finally! Great!
NOTE:
Comments that will hurt anyone in any way will be deleted.
Don't ask for features, advertise or curse.
If you want to leave a message to the author use the contacts,
if you have any question in relation to your comments please use the forum.
Comments which violate any of these requests will be deleted without further
notice. Use the comment system decently.

Post your comment:
Name:
email:
Comment:
::Top 5 Tutorials::
Embedded Python[108311]
2D Rotated Rectangles Collision Detection[81437]
Keyboard Hook[70363]
UDP[53824]
HTTP Proxy[37096]

::Top 5 Samples::
2D ColDet Rotated Rectangles[10744]
PS2 Mouse Driver[6216]
Wave Format Player[5091]
Reading FAT12[4978]
CodeGuru[4676]


All rights reserved to RageStorm © 2009