Hi
Here is the steps to start working with Media Player on a MFC Dialog based application
1: Create a new dialog based MFC application
2: Open dialog designer and remove default label control that's created by VS template
3: Right click in dialog and select insert activex control
4: Select and insert Windows Media Player control to dialog
5: Resize and reposition control as you whish
6: Right click to control and select
Add Variable
7: Enter
m_MediaPlayer
(or whatever you want) as the control variable without changing any other property
8: This will add a
ocx1.h
and a
ocx1.cpp
to the project , and
#include "ocx1.h"
is also added to main dialog
9: Open
stdafx.h
and add this
#include <wmp.h>
include directive to it
10: Open header file of Dialog class that contains Media Player object and add this
CComPtr<IWMPPlayer> m_pWMPPlayer;
variable to somewhere in it
11: Now open CPP file of dialog class and goto OnInitDialog() and add following code
LPUNKNOWN pUnknown = m_MediaPlayerControl.GetControlUnknown();
HRESULT hr = pUnknown->QueryInterface(__uuidof(IWMPPlayer), (void**)&m_pWMPPlayer);
if(SUCCEEDED(hr))
{
CComBSTR strMovie = _T("Full Path To Movie File");
m_pWMPPlayer->put_URL(strMovie);
}
12: Build and see result
If you want to implement more functionality of Media Player then
Take a look at available interfaces of Media Player at MSDN site
Interfaces (Windows Media Player)[
^]