Simple programming of multimedia MCI

Source: Internet
Author: User

MCI is an interface for Windows to provide multimedia devices.

 

To program MCI, send the mci_open command to open the device ---> send the mci_play command to play the device ----> send the mci_cloase

 

The mcisendcommand function can be used to send a command to a specified device. The definition of mcisendcommand is as follows:

 

Mcierror mcisendcommand (<br/> mcideviceid iddevice, // device ID <br/> uint umsg, // command type <br/> DWORD fdwcommand, // command flag <br/> DWORD dwparam // command parameter <br/>); <br/> 

 

 

The following example shows how to enable MP3 file playback.

 

# Include "stdafx. H "<br/> # include <mmsystem. h> <br/> # pragma comment (Lib, "winmm. lib "); <br/> int apientry winmain (hinstance, <br/> hinstance hprevinstance, <br/> lpstr lpcmdline, <br/> int ncmdshow) <br/> {<br/> // 1. open the device <br/> mci_open_parms openparms; // The mci_open Command requires a parameter struct <br/> openparms. lpstrdevicetype = "mpegvideo"; // The file device ID of MP3 is mpegvideo <br/> openparms. lpstrelementname = "C: // 1. MP3 "; // path for storing MP3 files <br/> // sending command <br/> mcisendcommand (<br/> null, // No device ID is required to open the device <br/> mci_open, // mci_open. This command indicates to open the device <br/> mci_open_element | mci_open_type | mci_wait, <br/> (DWORD) (lpvoid (& openparms ))); // pass the authorization parameter <br/>/* mci_open_element indicates that the lpstrelementname of mci_open_parms is valid <br/> mci_open_type indicates that the authorization lpstrdevicetype is valid <br/> mci_wait indicates that the command will be, knowing that the operation is complete <br/> (if mci_policy is used, the command will be returned immediately after being sent, and a notification message will be sent after the operation is completed) */</P> <p> // after the device is enabled, the device ID is stored in openparms. in wdeviceid, <br/> word m_wdeviceid = openparms. wdeviceid; <br/> // 2. Playback Device <br/> mci_play_parms playparms; // parameter struct required by the mci_play command <br/> mcisendcommand (<br/> m_wdeviceid, // The required device ID <br/> mci_play, // This command plays the device <br/> mci_wait, // wait until the playback file ends, and then return <br/> (DWORD) (lpvoid (& playparms); // pass the mci_play_parms parameter <br/> // 3. Disable the device <br/> mcisendcommand (<br/> m_wdeviceid, <br/> mci_close, <br/> null, <br/> null); <br/> return 0; <br/>}</P> <p> 

 

 

The formats supported by MCI are limited. Therefore, it may be difficult to develop a player. However, it is good to make alarms and prompt music.

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.