案例6:播放音频文件.ppt
《案例6:播放音频文件.ppt》由会员分享,可在线阅读,更多相关《案例6:播放音频文件.ppt(38页珍藏版)》请在三一办公上搜索。
1、2023/9/26,成都信息工程学院 计算机学院,1,案例6:播放音频文件,2023/9/26,成都信息工程学院 计算机学院,2,需求与目标,在多媒体程序的设计中经常需要处理声音文件。,2023/9/26,成都信息工程学院 计算机学院,3,思路,媒体控制接口(MCI)提供了控制多媒体设备的一组与设备无关的命令消息和命令串。Wondows支持两种RIFF(Resource Interchage File Format资源交互文件格式)音频文件:MIDI文件和WAV文件。本例子说明MIDI文件的播放方法。,2023/9/26,成都信息工程学院 计算机学院,4,思路,程序只提供3种基本的操作:选择声
2、音文件播放停止,2023/9/26,成都信息工程学院 计算机学院,5,编程步骤(1),用AppWizard建立一个基于对话框的工程MyPlayer,2023/9/26,成都信息工程学院 计算机学院,6,编程步骤(2),按照如下方式完成对话框界面的设计:,2023/9/26,成都信息工程学院 计算机学院,7,编程步骤(2),2023/9/26,成都信息工程学院 计算机学院,8,编程步骤(2),2023/9/26,成都信息工程学院 计算机学院,9,编程步骤(2),2023/9/26,成都信息工程学院 计算机学院,10,编程步骤(2),2023/9/26,成都信息工程学院 计算机学院,11,编程步骤
3、(2),2023/9/26,成都信息工程学院 计算机学院,12,编程步骤(2),2023/9/26,成都信息工程学院 计算机学院,13,编程步骤(3),为EditBox绑定一个变量,用来记录要播放的声音文件的路径。,2023/9/26,成都信息工程学院 计算机学院,14,编程步骤(3),2023/9/26,成都信息工程学院 计算机学院,15,编程步骤(4),为“浏览”按钮添加Click的响应函数,2023/9/26,成都信息工程学院 计算机学院,16,编程步骤(4),2023/9/26,成都信息工程学院 计算机学院,17,编程步骤(4),在OnBtnBrowser()中添加选择声音文件的代码C
4、FileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,Midi Files(*.mid)|*.mid);if(IDOK=dlg.DoModal()m_strFilePath=dlg.GetPathName();UpdateData(FALSE);,2023/9/26,成都信息工程学院 计算机学院,18,CFileDialog,The CFileDialog class encapsulates the Windows common file dialog box,which provides an easy way
5、 to implement the standard File Open and File Save As dialog boxes.,2023/9/26,成都信息工程学院 计算机学院,19,CFileDialog:CFileDialog,CFileDialog(BOOL bOpenFileDialog,LPCTSTR lpszDefExt=NULL,LPCTSTR lpszFileName=NULL,DWORD dwFlags=OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,LPCTSTR lpszFilter=NULL,CWnd*pParentWnd=NULL);
6、,2023/9/26,成都信息工程学院 计算机学院,20,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.,2023/9/26,成都信息工程学院 计算机学院,21,Parameters,bOpenFileDialogSet to TRUE to construct a File
7、 Open dialog box or FALSE to construct a File Save As dialog box.lpszDefExtThe 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
8、appended.lpszFileNameThe initial filename that appears in the filename edit box.If NULL,no filename initially appears.,2023/9/26,成都信息工程学院 计算机学院,22,Parameters,dwFlagsA combination of one or more flags that allow you to customize the dialog box.For a description of these flags,see the OPENFILENAME str
9、ucture in the Win32 SDK documentation.If you modify the m_ofn.Flags structure member,use a bitwise-OR operator in your changes to keep the default behavior intact.lpszFilterA series of string pairs that specify filters you can apply to the file.If you specify file filters,only selected files will ap
10、pear in the Files list box.See the Remarks section for more information on how to work with file filters.pParentWndA pointer to the file dialog-box objects parent or owner window.,2023/9/26,成都信息工程学院 计算机学院,23,lpszFilter,Chart Files(*.xlc)|*.xlc|Worksheet Files(*.xls)|*.xls|Data Files(*.xlc;*.xls)|*.x
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 案例 播放 音频文件

链接地址:https://www.31ppt.com/p-6119618.html