- 46
- 0
- 约 38页
- 2017-09-29 发布于江西
- 举报
案例:播放音频文件 需求与目标 在多媒体程序的设计中经常需要处理声音文件。 思路 媒体控制接口(MCI)提供了控制多媒体设备的一组与设备无关的命令消息和命令串。 Wondows支持两种RIFF(Resource Interchage File Format——资源交互文件格式)音频文件:MIDI文件和WAV文件。 本例子说明MIDI文件的播放方法。 思路 程序只提供3种基本的操作: 选择声音文件 播放 停止 编程步骤(1) 用AppWizard建立一个基于对话框的工程MyPlayer 编程步骤(2) 按照如下方式完成对话框界面的设计: 编程步骤(2) 编程步骤(2) 编程步骤(2) 编程步骤(2) 编程步骤(2) 编程步骤(2) 编程步骤(3) 为EditBox绑定一个变量,用来记录要播放的声音文件的路径。 编程步骤(3) 编程步骤(4) 为“浏览”按钮添加Click的响应函数 编程步骤(4) 编程步骤(4) 在OnBtnBrowser()中添加选择声音文件的代码 CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, Midi Files (*.mid)|*.mid); if (IDOK == dlg.DoModal()) { m_strFilePath = dlg.GetPathName(); UpdateData(FALSE); } CFileDialog The CFileDialog class encapsulates the Windows common file dialog box, which provides an easy way to implement the standard File Open and File Save As dialog boxes. CFileDialog::CFileDialog CFileDialog( BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL, DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL ); Remarks Call this function to construct a standard Windows file dialog box-object. Either a File Open or File Save As dialog box is constructed, depending on the value of bOpenFileDialog. Parameters bOpenFileDialog Set to TRUE to construct a File Open dialog box or FALSE to construct a File Save As dialog box. lpszDefExt The default filename extension. If the user does not include an extension in the Filename edit box, the extension specified by lpszDefExt is automatically appended to the filename. If this parameter is NULL, no file extension is appended. lpszFileName The initial filename that appears in the filename edit box. If NULL, no filename initially appears. Parameters dwFlags A combination of one or more flags that allow you to customize the dialog box. For a description of these flags, see the OPENFILENAME structure in the Win32 SDK documentation. If you modify the m_ofn.Flags structure member, use a bitwise-OR operator in your
原创力文档

文档评论(0)