vc200320052008 调用mediaplayer的指南.pdf





《vc200320052008 调用mediaplayer的指南.pdf》由会员分享,可在线阅读,更多相关《vc200320052008 调用mediaplayer的指南.pdf(12页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、VC+200320052008 调用 Mediaplayer 的指南,通过对CWMPPlayer4、CWMPSettings 和CWMPControls等几个类的使用可以实现 Windows Media Player 的大部分常规功能,如果需要做进一步的控制,可以在用下面这些函数返回相关类对象后调用相关成员函数来加以实现:GetCurrentMedia()返回 CWMPMedia 类对象GetMediaCollection()返回 CWMPMediaCollection 类对象GetPlaylistCollection()返回 CWMPPlaylistCollection 类对象GetNetw
2、ork()返回 CWMPNetwork 类对象GetCurrentPlaylist()返回 CWMPPlaylist 类对象GetCdromCollection()返回 CWMPCdromCollection 类对象GetClosedCaption()返回 CWMPClosedCaption 类对象GetError()返回 CWMPError 类对象GetDvd()返回CWMPDVD 类对象GetPlayerApplication()返回CWMPPlayerApplication 类对象1、新建一个基于对话框的 mfc 应用程序。2、在工具箱上点右键选择“选择项”,打开com 组件,选择win
3、dows media player 添加到工具箱上。3、把 media 控件拖到窗体上.选中窗体。在菜单上选择 项目-添加类-MFC->activex 控件中的 mfc 类-添加。4、选择 windows media player<1.0>,添加 IWMPControls类。5、在 xxxDlg.h 中添加:#include CWMPControls.h。public:COcx1 mm;/Ocx1 为 media 控件,mm 为控件变量。CWMPControlsm_control;6、在 xxxDlg.cpp 文件中 OnInitDialog()函数中添加:m_control
4、=static_cast<CWMPControls>(mm.get_controls();7、现在你可以用 mm.put_URL 去干你的事情了。另外一种办法,直接用 COM 操作,例如:CAxWindow*m_pView;CComObject<IWMPPlayer4>m_spPlayer;RECT rcClient;CComPtr<IObjectWithSite>spHostObject;CComPtr<IAxWinHostWindow>spHost;CComObject<CRemoteHost>*pRemoteHost=NULL;
5、/创建 ActiveX 控件容器AtlAxWinInit();m_pView=new CAxWindow();if(!m_pView)hr=E_OUTOFMEMORY;if(SUCCEEDED(hr):GetWindowRect(GetDlgItem(IDC_RANGE),&rcClient);ScreenToClient(&rcClient);m_pView->Create(m_hWnd,rcClient,NULL,WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN,WS_EX_CLIENTEDGE);if(:IsWindow(m_pView->
6、;m_hWnd)hr=m_pView->QueryHost(IID_IObjectWithSite,(void*)&spHostObject);if(!spHostObject.p)hr=E_POINTER;/创建 IServiceProvider and IWMPRemoteMediaServicesif(SUCCEEDED(hr)hr=CComObject<CRemoteHost>:CreateInstance(&pRemoteHost);if(pRemoteHost)pRemoteHost->AddRef();elsehr=E_POINTER;/S
7、et site to the remote hostif(SUCCEEDED(hr)hr=spHostObject->SetSite(IWMPRemoteMediaServices*)pRemoteHost);if(SUCCEEDED(hr)hr=m_pView->QueryHost(&spHost);if(!spHost.p)hr=E_NOINTERFACE;/创建 WindowsMediaPlayer 的控件if(SUCCEEDED(hr)hr=spHost->CreateControl(CComBSTR(L6BF52A52-394A-11d3-B153-00C0
8、4F79FAA6),m_pView->m_hWnd,NULL);if(SUCCEEDED(hr)hr=m_pView->QueryControl(&m_spPlayer);if(!m_spPlayer.p)hr=E_NOINTERFACE;/Set skin to be custom skinif(SUCCEEDED(hr)DispEventAdvise(m_spPlayer);/Hook the eventlistenerhr=m_spPlayer->put_uiMode(CComBSTR(_T(custom);.m_spPlayer->put_URL(.);
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- vc 200320052008 调用mediaplayer的指南 调用 mediaplayer 指南

限制150内