我正在尝试将嵌入的Window Media Player嵌入MFC中的对话框中。我正在使用这些步骤:
现在我想在运行时运行视频文件。为此,我正在写一些内部
OnInitDialog()
我在OnInitDialog()
BOOL CPlayerDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
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("abcd.mp3"));
hr = pControls->play();
hr = pControls->Release();
hr = pPlayer->Release();
return TRUE; // return TRUE unless you set the focus to a control
}
此处oleObject
的类型为IOleObject*
现在我无法看到视频,但我可以听取并放弃窗口媒体播放器的所有功能,例如增加或减少音量,播放按钮被禁用。我想运行具有窗口媒体播放器所有功能的音频/视频文件。
我从这些文章中获得了帮助:
http://msdn.microsoft.com/en-us/library/dd564580(VS.85).aspx
任何人都可以帮助我。