盘绰网教程:是一个免费提供流行视频软件教程、在线学习分享的学习平台!

大型WAV文件的播放

时间:2022/11/22作者:未知来源:盘绰网教程人气:


[摘要]MCI_WAIT, (DWORD)(LPVOID)&mciOpenParms); //save device identifier,will use eith other MCI comma...
MCI_WAIT, (DWORD)(LPVOID)&mciOpenParms); //save device identifier,will use eith other MCI commands

m_nDeviceID=mciOpenParms.wDeviceID; //display error message if failed if(dwResult)

DisplayErrorMsg(dwResult);

} //return result of MCI operation return dwResult;   }   

DWORD CWave::CloseDevice()   

{   

DWORD dwResult=0; //close if currently open if(m_nDeviceID) { //close the MCI device

dwResult=mciSendCommand(m_nDeviceID,MCI_CLOSE,NULL,NULL); //display error message if failed

if(dwResult) DisplayErrorMsg(dwResult); //set identifier to close state else m_nDeviceID=0; } //return result of MCI operation return dwResult;   

}   

DWORD CWave::Play(CWnd* pWnd,LPCSTR pFileName)   

{

MCI_OPEN_PARMS mciOpenParms; //initialize structure

memset(&mciOpenParms,0,sizeof(MCI_OPEN_PARMS)); //set the WAV file name to be played

mciOpenParms.lpstrElementName=pFileName; //first open the device DWORD

dwResult=mciSendCommand(m_nDeviceID,MCI_OPEN, MCI_OPEN_ELEMENT,(DWORD)(LPVOID)&mciOpenParms); //display error message if failed if(dwResult)

DisplayErrorMsg(dwResult); //if successful,instruct the device to play the WAV file else { //save element indentifier m_nElementID=mciOpenParms.wDeviceID; MCI_PLAY_PARMS mciPlayParms; //set the window that will receive notification message

mciPlayParms.dwCallback=(DWORD)pWnd->m_hWnd; //instruct device to play file

dwResult=mciSendCommand(m_nElementID,MCI_PLAY, MCI_NOTIFY,(DWORD)(LPVOID)&mciPlayParms); //display error and close element if failed if(dwResult) { DisplayErrorMsg(dwResult); Stop(); }

} //return result of MCI operation return dwResult;   }   

DWORD CWave::Stop()   

{   

DWORD dwResult=0;    //close if element is currently open    if(m_nElementID)    {   

dwResult=mciSendCommand(m_nElementID,MCI_CLOSE,NULL,NULL);    //display error message if failed   

if(dwResult)    DisplayErrorMsg(dwResult);    //set identifier to closed state    else  

m_nElementID=0;   

return dwResult;   

}   

void CWave::DisplayErrorMsg(DWORD dwError)   

{    //check if there was an error   

if(dwError)   

{    //character string that contains error message   

char szErrorMsg[MAXERRORLENGTH];    //retrieve string associated error message   

if(!mciGetErrorString(dwError,szErrorMsg,sizeof(szErrorMsg)))    strcpy(szErrorMsg,"Unknown Error");    //display error string in message box   

AfxMessageBox(szErrorMsg);   

}   

}  

关键词:  大型WAV文件的播放





Copyright © 2012-2018 盘绰网教程(http://www.panchuo.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版