-
大小: 72KB文件類型: .zip金幣: 2下載: 0 次發(fā)布日期: 2021-05-10
- 語言: C/C++
- 標(biāo)簽: CWMPPlayer4??
資源簡(jiǎn)介
CWMPPlayer4類做的視頻播放器
舉例:
1. 新建一個(gè)基于對(duì)話框的應(yīng)用程序
2. 刪除默認(rèn)控件,增加一個(gè)按鈕控件,ID設(shè)為ID_OPEN;
3. 在對(duì)話框的空白處右鍵插入ActiveX控件,選擇Windows Media Player。注意:路徑為C:\WINDOWS\system32\wmp.dll
4. 為ActiveX控件關(guān)聯(lián)一個(gè)CWMPPlayer4類型的變量m_player;注意,添加相應(yīng)的類。(這些有VC6.0自動(dòng)添加)
5. 為第2步的按鈕控件添加消息處理響應(yīng)函數(shù),實(shí)現(xiàn)文件的打開,并將文件的路徑設(shè)置為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;
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????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個(gè)文件信息
評(píng)論
共有 條評(píng)論