MSDN
Name or constant identifier of the device type. (The name of the device is typically obtained from the registry or SYSTEM.INI file.) If this member is a constant, it can be one of the values listed in
The following values identify devices in MCI messages and structures:
Value | Meaning |
---|
MCI_ALL_DEVICE_ID | Any device |
MCI_DEVTYPE_ANIMATION | Animation-playback device |
MCI_DEVTYPE_CD_AUDIO | CD audio device |
MCI_DEVTYPE_DAT | Digital-audio tape device |
MCI_DEVTYPE_DIGITAL_VIDEO | Digital-video playback device |
MCI_DEVTYPE_OTHER | Undefined device |
MCI_DEVTYPE_OVERLAY | Video-overlay device |
MCI_DEVTYPE_SCANNER | Scanner device |
MCI_DEVTYPE_SEQUENCER | MIDI sequencer device |
MCI_DEVTYPE_VCR | Video-cassette recorder |
MCI_DEVTYPE_VIDEODISC | Videodisc player |
MCI_DEVTYPE_WAVEFORM_AUDIO | Waveform-audio device |
实在看不懂,好像9X时代的东东.最后终于在注册表中找到了.
HKEY_LOCAL_MACHINE/Software/Microsoft/Windows NT/CurrentVersion/MCI Extensions中有所有的文件类型,和相对应的播放设备。
MCI播放mp3的例子:
#include<windows.h>
#include<stdio.h>
#include<mmsystem.h>
#pragma comment(lib,"winmm.lib")
void main()
{
char buf[128];
//use mciSendString()
//mciSendString("play e://songs//把根留住.mp3",buf,sizeof(buf),NULL);
//mciSendString("play e://songs//zhj.mp3",buf,sizeof(buf),NULL);
char str[128] = {0 };
int i = 0;
//use mciSendCommand
MCI_OPEN_PARMS mciOpen;
MCIERROR mciError;
SetWindowText(NULL,"12345");
//mciOpen.lpstrDeviceType = (LPCTSTR)MCI_ALL_DEVICE_ID;
//mciOpen.lpstrDeviceType = "waveaudio"; //只能播放.wav文件
//mciOpen.lpstrDeviceType = "avivideo"; //*.avi
mciOpen.lpstrDeviceType = "mpegvideo";
//mciOpen.lpstrDeviceType = "sequencer";
mciOpen.lpstrElementName = "e://songs//zhj.mp3";
//mciOpen.lpstrElementName = "e://movie//first.avi";
//mciOpen.lpstrElementName = "c://winnt//media//Windows 登录音.wav";
mciError = mciSendCommand(0,MCI_OPEN,MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,(DWORD)&mciOpen);
if(mciError)
{
mciGetErrorString(mciError,buf,128);
printf("send MCI_OPEN command failed:%s/n",buf);
return;
}
UINT DeviceID = mciOpen.wDeviceID ;
MCI_PLAY_PARMS mciPlay;
mciError = mciSendCommand(DeviceID,MCI_PLAY,0 ,(DWORD)&mciPlay);
if(mciError)
{
printf("send MCI_PLAY command failed/n");
return;
}
/*
while(1)
{
sprintf(str,"now playing/t%d/tseconds",i);
printf("%s/r",str);
i++;
Sleep(1000);
}
*/
}