GM: MCI command

From GMpedia.org Wiki

Jump to: navigation, search
The correct title of this article is GM: MCI_command.

MCI_command
 

Type: function
Arguments: 1: command string;
Limitations: Registered

The MCI_command function is a function in Game Maker allows you to interact with Windows' Multimedia Control Interface (MCI). You need to be registered to be able to use it.

Note that this function, when used correctly, can also return a value.

Contents

[edit] Examples of use in Game Maker

[edit] Example 1 : play a media file

Depending on installed MCI devices on your computer, you can play media files from different formats. Especially the device MPEGVideo supports many formats, such as ogg, mp3, wmv, avi, mpeg, ... Please note that this device is not installed on all Windows computers. It is a software device, though, and can be used by installing the mciqtz32 driver and changing some registry settings.

First, you need to open an MCI device and preferrably assign an alias to it. Suppose we want to open the waveaudio device to play a wave file called sound.wav

MCI_command('open "sound.wav" type waveaudio alias "audio"');

Now the device is opened and the file sound.wav is loaded into the device. Do not expect that it will automatically play the wave file.

The following command will perform that action:

MCI_command('play "audio"');

Important: remember to use the alias you provided instead of the device name!

[edit] Example 2 : check the status of a device

You can check the status of an open device to check whether it is playing, stopped, recording, paused or seeking.

In the following example, the device alias "device" will be used to indicate the device.

var status;
status=MCI_command('status "device" mode');
return status;

If you use this piece of code in a script, the status of the device will be returned. MSDN MCI Command String Reference, Microsoft

[edit] References

Personal tools