I am trying to embed the embed Window Media Player in a dialog in MFC. I am using these steps:
I created one new dialog based application in mfc
Right Click on dialog->Insert ActivexControl->Window Media Player
Now I want to run a video file at run time. For that I am writing some code inside
OnInitDialog()
I am writing this code inside
OnInitDialog()
BOOL CPlayerDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
HRESULT hr = CoCreateInstance(__uuidof(WindowsMediaPlayer), 0, CLSCTX_INPROC_SERVER, IID_IOleObject, (void**)&oleObject);
IWMPPlayer4* pPlayer = NULL;
hr = oleObject->QueryInterface(__uuidof(IWMPPlayer4), (void**)&pPlayer);
pPlayer->put_uiMode(_T("full"));
IWMPSettings *pSettings=NULL;
hr = pPlayer->QueryInterface(__uuidof(IWMPSettings), (void **)&pSettings);
IWMPControls *pControls = NULL;
hr = pPlayer->QueryInterface(__uuidof(IWMPControls), (void **)&pControls);
hr = pPlayer->put_enabled(VARIANT_TRUE);
hr = pPlayer->put_URL(_T("d:\\abcd.mp4"));
hr = pControls->play();
hr = pControls->Release();
hr = pPlayer->Release();
return TRUE;
}
here
oleObject
is of type
IOleObject*
Now I am not able to see the video but I can listen and loose all functionality of window media player like increase or decrease the volume and Play button got disabled. I want to run audio/video files with all functionality of window media player.
I took help from these articles:
http:
Can anyone help me.