Click here to Skip to main content
15,894,291 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I'm just use directshow for some days, I directly use MPC-BE filters.
After input file name,then click play button:
C++
void CAFPlayerDlg::OnBnClickedButtonPlay()
{
    HRESULT hr = NOERROR;
    CString fileName;
    m_edtFileName.GetWindowTextW(fileName);

    if(fileName.GetLength() <= 0)
        return;

    hr = m_pGraph->RenderFile(fileName.GetBuffer(), NULL);
    fileName.ReleaseBuffer();

    if(FAILED(hr))
        return;

    hr = m_pME->SetNotifyWindow((OAHWND)this->GetSafeHwnd(), WM_GRAPHNOTIFY, 0);
    SetDisplayWindow(m_stcVideoWindow.GetSafeHwnd());

    if(SUCCEEDED(hr)) {
        m_pMC->Run();
    }
}


SetDisplayWindow function is:
C++
bool CAFPlayerDlg::SetDisplayWindow( HWND displayWindow )
{
    if(m_pVideoWindow) {
        m_pVideoWindow->put_Visible(OAFALSE);
        m_pVideoWindow->put_Owner((OAHWND)displayWindow);

        RECT rect;
        ::GetClientRect(displayWindow, &rect);
        m_pVideoWindow->put_Left(0);
        m_pVideoWindow->put_Top(0);
        m_pVideoWindow->put_Width(rect.right - rect.left);
        m_pVideoWindow->put_Height(rect.bottom - rect.top);
        m_pVideoWindow->put_WindowStyle(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); 

        m_pVideoWindow->put_MessageDrain((OAHWND)displayWindow);

        if(displayWindow) {
            m_pVideoWindow->put_Visible(OATRUE);
        } else {
            m_pVideoWindow->put_Visible(OAFALSE);
        }

        return true;
    }

    return false;
}


I has add some code for refreshing:
C++
BOOL CAFPlayerDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();

    m_stcVideoWindow.ModifyStyle(0, WS_CLIPCHILDREN);

    CoInitialize(NULL);
    
    return TRUE;
}

BOOL CAFPlayerDlg::OnEraseBkgnd(CDC* pDC)
{
    CRect rc;
    // Get the bounding rectangle for the movie screen
    m_stcVideoWindow.GetWindowRect(&rc);
    ScreenToClient(&rc);
    // Exclude the clipping region occupied by our movie screen
   pDC->ExcludeClipRect(&rc);

    // Erase the remainder of the dialog as usual
    return CDialog::OnEraseBkgnd(pDC);
}

void CAFPlayerDlg::PreSubclassWindow()
{
    CDialog::PreSubclassWindow();
    this->ModifyStyle( 0, WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0 );
}


Now I can play mp4 file, I can hear music sound, but display is not normal.
Please see image:
[https://drive.google.com/file/d/0BwyCt3NztyAPZFdkM2N3ZnoyczQ/edit?usp=sharing[^]]
Posted
Updated 1-Apr-14 16:52pm
v2
Comments
Sergey Alexandrovich Kryukov 1-Apr-14 22:54pm    
"not normal" is not informative.
—SA
Jeffery Jiang 1-Apr-14 22:55pm    
Please see image on https://drive.google.com/file/d/0BwyCt3NztyAPZFdkM2N3ZnoyczQ/edit?usp=sharing

1 solution

You have video decoder issue.
If you uses the defalt decoder, try to specify it manually in filter graph, or specify other one if you already uses your own decoder.

Regards,
Maxim.
 
Share this answer
 
Comments
Jeffery Jiang 14-Apr-14 0:26am    
my application's filter graph is as same as GraphEdit built, just one difference is I specified a video window handle.
Jeffery Jiang 14-Apr-14 0:28am    
and i use my app plays rmvb file,is ok.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900