实验简单音频播放器程序实现
#endif
CMyDlg dlg。
m_pMainWnd = &dlg。
int nResponse = dlg.DoModal()。
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
void CMUSIC_PLAYER_100511217Dlg::OnCustomdrawSlider(NMHDR* pNMHDR, LRESULT* pResult)
{
UpdateData(true)。
m_vol=m_slider.GetPos()/10。
SetVolumn(m_slider.GetPos())。
// The one and only CMyApp object
CMyApp theApp。
/////////////////////////////////////////////////////////////////////////////
// CMyApp initialization
BOOL CMyApp::InitInstance()
1、点击“打开”,添加播放资源
2、单击“播放”,开始播放
3、点击“暂停”,暂停播放;之后点击“恢复”,播放器继续播放
4、单击“终止”,音乐播放停止
5、滑动音量滑块调节音量大小
五、调试过程及实验结果
本次作业参考了优酷上的指导视频,然后仿照编写的。
在完成此次大作业的过程中遇到了很多问题,首先音量控制就是一个难点,最初完成的版本可以运行但音量无法控制,后来添加了一个函数解决问题:
UpdateData(false)。
*pResult = 0。
}
最终成果:
六、总结
过完成这个简易的音乐播放器,掌握到了MFC编程的基本方法,使自己的编程能力得到进一步的提高,学会使用DirectSound实现音频播放程序的方法。
7、附录
player.cpp
// player.cpp : Defines the class behaviors for the application.
{
AfxEnableControlContainer()。
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls()。// Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic()。// Call this when linking to MFC statically
实验2简单音频播放器程序实现
1.
课程名称:多媒体技术
班级:数媒**班
实验日期:2014.3.31-4.11
小组成员:
指导教师:
实验序号:02
实验成绩:
一、简单音频播放器程序实现
二、实验目的及要求
1、掌握使用DirectSound实现音频播放程序的方法;
2、掌握创建缓冲区的方法;
3、学会播放音频数据的方法;
// CMyApp construction
CMyApp::CMyApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
//
#include "stdafx.h"
#include "player.h"
#include "playerDlg.h"
#if#undef THIS_FILE
static char THIS_FILE[] = __FILE__。
#endif
3、了解RIFF文件格式,学会读取WAV文件的方法;
4、开发一个简单的基于MFC框架的音频播放器。
三、实验环境
本次上机实践所使用的平台和相关软件
VS2012MFC\win7
四、实验内容
用MFC设计具有一般能播放*.mp3,*.wma,*.mdi,*.wav,*.avi,*.dat等文件,还有具有播放、暂停、停止、音量调节等功能。
/////////////////////////////////////////////////////////////////////////////
// CMyApp
BEGIN_MESSAGE_MAP(CMyApp, CWinApp)
//{{AFX_MSG_MAP(CMyApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the