gpt4 book ai didi

c++ - 在mfc中嵌入Window Media Player

转载 作者:太空宇宙 更新时间:2023-11-04 11:25:00 26 4
gpt4 key购买 nike

我在基于对话框的 mfc 应用程序中嵌入了一个窗口媒体播放器 activex 控件。现在所有的播放/暂停按钮都被禁用了。我想启用它们。

正如我在 put_uiMode(_T("mini"));并且在写这些行的时候

hr = m_spWMPPlayer->put_fullScreen(VARIANT_TRUE)
hr = m_spWMPPlayer->get_fullScreen(&b); // returned b = VARIANT_FALSE

b 的值变为 FALSE。

可能是什么错误?有人知道吗?

谢谢

BOOL CLuminPlayerDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();

CComPtr<IWMPPlayer> m_spWMPPlayer;
CComPtr<IWMPRemoteMediaServices> m_spServices;
CComPtr<IWMPControls> m_spControls;

// 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 = NULL;
if(SUCCEEDED(hr))
{
hr = CoCreateInstance(__uuidof(WindowsMediaPlayer), 0, CLSCTX_INPROC_SERVER, IID_IOleObject, (void**)&m_spServices);

if(SUCCEEDED(hr))
{
BSTR str = NULL;

VARIANT_BOOL b ;
hr = m_spServices->QueryInterface(__uuidof(IWMPPlayer), (void**)&m_spWMPPlayer);
if(SUCCEEDED(hr))
{

hr = m_spWMPPlayer->get_enabled(&b); // returned b= VARIANT_TRUE
hr = m_spWMPPlayer->get_enableContextMenu(&b); //returned b = VARIANT_TRUE
hr = m_spWMPPlayer->get_uiMode(&str); // returned str = L"full"
hr = m_spWMPPlayer->put_uiMode(_T("mini")); //hr = S_OK
hr = m_spWMPPlayer->get_uiMode(&str); // str = L"mini"
hr = m_spWMPPlayer->put_fullScreen(VARIANT_TRUE);
hr = m_spWMPPlayer->get_fullScreen(&b); // returned b = VARIANT_FALSE
hr = m_spWMPPlayer->put_URL(_T("C:\\Visual Studio 2012\\Projects\\Lumin-Player\\Debug\\abc.mp4")); //returned hr = S_OK

hr = m_spServices->QueryInterface(__uuidof(IWMPControls), (void**)&m_spControls); // returned hr = S_OK
if(SUCCEEDED(hr))
{
hr = m_spControls->play(); //returned hr = S_OK
}
}
}
}

return TRUE; // return TRUE unless you set the focus to a control
}

最佳答案

MSDN says :

For full-screen mode to work properly when embedding the Windows Media Player control, the video display area must have a height and width of at least one pixel. If the BSTR specified in IWMPPlayer::put_uiMode is set to "mini" or "full", the height of the control itself must be 65 pixels or greater to accommodate the video display area in addition to the user interface.

这假定播放器已正确初始化为 ActiveX 控件。在您的代码中,您只需创建一个 COM 对象,而无需进行任何 ActiveX 控件初始化。据推测,播放器会检测到这一点并报告错误。

您在相应 put_fullScreen 调用中的 hr 应该有 0xC00D0FD2 NS_E_WMPOCX_NO_ACTIVE_CORE “请求的方法或属性不可用因为 Windows Media Player ActiveX 控件没有被正确激活。”指出问题。

关于c++ - 在mfc中嵌入Window Media Player,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26987253/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com