|
原文连接:http://eightquit.com/post/256668_8d919e 其实是调用微软的mci播放工具 呵呵 挺简单的我只是写了一个粗糙版的 大家自己完善就可以了
BOOL CTestMciDlg::mciExecute(LPCTSTR szCommand) { MCIERROR error ; TCHAR szErrorStr [1024] ; if (error = mciSendString (szCommand, NULL, 0, NULL)) { mciGetErrorString (error, szErrorStr, sizeof (szErrorStr) / sizeof (TCHAR)) ; ::MessageBeep (MB_ICONEXCLAMATION) ; ::MessageBox (NULL, szErrorStr, TEXT ("MCI Error"), MB_OK | MB_ICONEXCLAMATION) ; } return error == 0 ; } void CTestMciDlg::OnBnClickedButton1()//播放 { if (!mciExecute (TEXT ("open record3.wav alias mysound"))) return; mciExecute (TEXT ("play mysound")) ; } void CTestMciDlg::OnBnClickedButton2()//录音 { // Delete existing waveform file DeleteFile (TEXT ("record3.wav")); // Open waveform audio and record if (!mciExecute (TEXT ("open new type waveaudio alias mysound"))) return; mciExecute (TEXT ("record mysound")) ; // Enable and disable buttons } void CTestMciDlg::OnBnClickedButton3()//停止 { mciExecute (TEXT ("stop mysound")) ; mciExecute (TEXT ("save mysound record3.wav")) ; mciExecute (TEXT ("close mysound")) ; }
|