在 MFC 中嵌入窗口媒体播放器



我正在基于对话框的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 说:

若要在嵌入Windows 媒体播放器控件时使全屏模式正常工作,视频显示区域的高度和宽度必须至少为一个像素。如果在 IWMPPlayer::p ut_uiMode 中指定的 BSTR 设置为"迷你"或"完整",则控件本身的高度必须为 65 像素或更大,以容纳除用户界面之外的视频显示区域。

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

在相应的put_fullScreen调用中的hr0xC00D0FD2 NS_E_WMPOCX_NO_ACTIVE_CORE"请求的方法或属性不可用,因为Windows 媒体播放器 ActiveX 控件尚未正确激活"以指示问题。

最新更新