-
大小: 72KB文件类型: .zip金币: 1下载: 0 次发布日期: 2021-05-10
- 语言: C/C++
- 标签: CWMPPlayer4
资源简介
CWMPPlayer4类做的视频播放器
举例:
1. 新建一个基于对话框的应用程序
2. 删除默认控件,增加一个按钮控件,ID设为ID_OPEN;
3. 在对话框的空白处右键插入ActiveX控件,选择Windows Media Player。注意:路径为C:\WINDOWS\system32\wmp.dll
4. 为ActiveX控件关联一个CWMPPlayer4类型的变量m_player;注意,添加相应的类。(这些有VC6.0自动添加)
5. 为第2步的按钮控件添加消息处理响应函数,实现文件的打开,并将文件的路径设置为m_player的播放路径。
代码如下:
char szFileFilter[]="Mp3 File(*.mp3)|*.mp3|"
"Wma File(*.wma)|*.wma|"
"Video File(*.dat)|*.dat|"
"Wave File(*.wav)|*.wav|"
"AVI File(*.avi)|*.avi|"
"Movie File(*.mov)|*.mov|"
"Media File(*.mmm)|*.mmm|"
"Mid File(*.mid;*,rmi)|*.mid;*.rmi|"
"MPEG File(*.mpeg)|*.mpeg|"
"All File(*.*)|*.*|| ";//文件类型过滤
CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY,szFileFilter);
if(dlg.DoModal()==IDOK)
{
CString PathName=dlg.GetPathName();
PathName.MakeUpper();
m_player.SetUrl(PathName);
}
代码片段和文件信息
// MyPlay.cpp : Defines the class behaviors for the application.
//
#include “stdafx.h“
#include “MyPlay.h“
#include “MyPlayDlg.h“
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyPlayApp
BEGIN_MESSAGE_MAP(CMyPlayApp CWinApp)
//{{AFX_MSG_MAP(CMyPlayApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP CWinApp::onhelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyPlayApp construction
CMyPlayApp::CMyPlayApp()
{
// TODO: add construction code here
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CMyPlayApp object
CMyPlayApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CMyPlayApp initialization
BOOL CMyPlayApp::InitInstance()
{
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
// 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
#endif
CMyPlayDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
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
// application rather than start the application‘s message pump.
return FALSE;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-04-30 20:58 MyPlay\
文件 26112 2012-04-30 21:29 MyPlay\CWmppla
文件 35876 2012-04-30 21:40 MyPlay\MyPlay.aps
文件 1143 2012-04-30 21:59 MyPlay\MyPlay.clw
文件 2063 2012-04-30 20:58 MyPlay\MyPlay.cpp
文件 9629 2012-04-30 22:00 MyPlay\MyPlay.dsp
文件 564 2012-04-30 22:00 MyPlay\MyPlay.dsw
文件 1324 2012-04-30 20:58 MyPlay\MyPlay.h
文件 99328 2012-04-30 22:00 MyPlay\MyPlay.ncb
文件 48640 2012-04-30 22:00 MyPlay\MyPlay.opt
文件 1571 2012-04-30 21:59 MyPlay\MyPlay.plg
文件 6236 2012-04-30 21:40 MyPlay\MyPlay.rc
文件 5271 2012-04-30 21:59 MyPlay\MyPlayDlg.cpp
文件 1480 2012-04-30 21:57 MyPlay\MyPlayDlg.h
文件 3579 2012-04-30 20:58 MyPlay\ReadMe.txt
目录 0 2012-04-30 20:58 MyPlay\res\
文件 776 2012-04-30 21:31 MyPlay\Resource.h
文件 1078 2012-04-30 20:58 MyPlay\res\MyPlay.ico
文件 398 2012-04-30 20:58 MyPlay\res\MyPlay.rc2
文件 208 2012-04-30 20:58 MyPlay\StdAfx.cpp
文件 1054 2012-04-30 20:58 MyPlay\StdAfx.h
文件 1017 2012-04-30 21:01 MyPlay\wmpcdrom.cpp
文件 1259 2012-04-30 21:01 MyPlay\wmpcdrom.h
文件 1277 2012-04-30 21:01 MyPlay\wmpcdromcollection.cpp
文件 1380 2012-04-30 21:01 MyPlay\wmpcdromcollection.h
文件 1943 2012-04-30 21:01 MyPlay\wmpclosedcaption.cpp
文件 1462 2012-04-30 21:01 MyPlay\wmpclosedcaption.h
文件 2882 2012-04-30 21:01 MyPlay\wmpcontrols.cpp
文件 1666 2012-04-30 21:01 MyPlay\wmpcontrols.h
文件 1233 2012-04-30 21:01 MyPlay\wmpdvd.cpp
文件 1220 2012-04-30 21:01 MyPlay\wmpdvd.h
............此处省略24个文件信息
- 上一篇:MFC画二维动态图表
- 下一篇:通过MFC和OpenGL实现点云数据的提取和显示
评论
共有 条评论