Waveform-Audio Dosyası Oynatma
[MCI bu sayfayla ilişkilendirilmiş özellik eski bir özelliktir. MediaPlayer tarafından yerini almıştır. MediaPlayer, Windows 10 ve Windows 11 için iyileştirilmiştir. Microsoft, yeni kodun mümkün olduğunda MCIyerine MediaPlayer kullanılmasını kesinlikle önerir. Microsoft, mümkünse yeni API'leri kullanmak için eski API'leri kullanan mevcut kodun yeniden yazılmasını önerir.]
Aşağıdaki örnek bir waveform-audio cihazı açar ve mciSendCommand işlevini kullanarak lpszWAVEFileName parametresi tarafından belirtilen waveform-audio dosyasını çalar.
// Plays a specified waveform-audio file using MCI_OPEN and MCI_PLAY.
// Returns when playback begins. Returns 0L on success, otherwise
// returns an MCI error code.
DWORD playWAVEFile(HWND hWndNotify, LPSTR lpszWAVEFileName)
{
UINT wDeviceID;
DWORD dwReturn;
MCI_OPEN_PARMS mciOpenParms;
MCI_PLAY_PARMS mciPlayParms;
// Open the device by specifying the device and filename.
// MCI will choose a device capable of playing the specified file.
mciOpenParms.lpstrDeviceType = "waveaudio";
mciOpenParms.lpstrElementName = lpszWAVEFileName;
if (dwReturn = mciSendCommand(0, MCI_OPEN,
MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,
(DWORD)(LPVOID) &mciOpenParms))
{
// Failed to open device. Don't close it; just return error.
return (dwReturn);
}
// The device opened successfully; get the device ID.
wDeviceID = mciOpenParms.wDeviceID;
// Begin playback. The window procedure function for the parent
// window will be notified with an MM_MCINOTIFY message when
// playback is complete. At this time, the window procedure closes
// the device.
mciPlayParms.dwCallback = (DWORD) hWndNotify;
if (dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_NOTIFY,
(DWORD)(LPVOID) &mciPlayParms))
{
mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
return (dwReturn);
}
return (0L);
}