In the Visual Studio .NET 2003 uses DirectShow to play media files (four)

zhaozj2021-02-16  60

// IDC_vw_frame control Picture Control main role is to control the display location of VEDIO WINDOW

Void CPlayWnddlg :: MoveVideoWindow (Void)

{

IvideoWindow * pvideoWinow = NULL;

IF (M_PGRAPH)

{

M_pgraph-> queryinterface (iid_ivideoWindow, (void **) & pvideowinow);

CRECT RC;

Getdlgitem (IDC_VW_FRAME) -> getWindowRect (RC);

ScreenToClient (RC);

PvideoWinow-> SetWindowPosition (rc.left, rc.top, rc.width (), rc.Height ());

PvideoWinow-> Release ();

PvideoWinow = NULL;

}

}

Void CPLAYWNDDLG :: Cleanup (void)

{

Long levcode;

IvideoWindow * pvidwin = null;

IF (! M_PGRAPH)

Return;

m_pgraph-> queryinterface (IID_IVideoWindow, (void **) & pvidwin);

M_PEVENT-> WaitForcompletion (Infinite, & Levcode);

PVIDWIN-> PUT_VISIBLE (OAFALSE);

Pvidwin-> release ();

m_pmediaseeping-> release ();

m_pmediacontrol-> release ();

M_PEVENT-> Release ();

m_pgraph-> release ();

m_pmediaseeking = null;

m_pmediacontrol = null;

m_pevent = NULL;

m_pgraph = NULL;

Updatedata (FALSE);

CclientDC DC (Getdlgitem (IDC_VW_Frame);

Dc.setbkcolor (RGB (0, 0, 0));

CRECT RC;

Getdlgitem (IDC_VW_FRAME) -> getClientRect (RC);

Clienttoscreen (RC);

Dc.FillRect (RC, CBRush :: fromHandle ((Hbrush) GetStockObject (Black_brush));

Invalidate ();

}

Bool CPlayWnddlg :: Stop (void)

{

IvideoWindow * pvidwin = null;

HRESULT HR;

IF (M_PMediaControl)

{

Longlong POS = 0;

HR = m_pmediacontrol-> stop ();

HR = m_pmediaseeking-> setPositions (& POS, am_seeking_absolutepositioning,

& POS, AM_Seeking_nopositioning;

m_pgraph-> queryinterface (IID_IVideoWindow, (void **) & pvidwin);

PVIDWIN-> PUT_VISIBLE (OAFALSE);

m_isplaming = false;

Getdlgitem (IDC_Play_Button) -> EnableWindow (TRUE);

Getdlgitem (IDC_PAUSE_BUTTON) -> EnableWindow (false); pvidwin-> Release ();

Long levcode;

M_PEVENT-> WaitForcompletion (Infinite, & Levcode);

m_pmediacontrol-> release ();

Return True;

}

Return False;

}

Bool CPlayWnddlg :: Play (void)

{

// run

IvideoWindow * pvidwin = null;

IF (M_PGRAPH)

{

m_pgraph-> queryinterface (IID_IVideoWindow, (void **) & pvidwin);

PVIDWIN-> PUT_Visible (OATRUE);

m_pgraph-> queryinterface (IID_IMEDIACONTROL, (Void **) & m_pmediacontrol);

m_pmediacontrol-> run ();

m_isplaming = true;

Getdlgitem (IDC_Play_Button) -> EnableWindow (false);

Getdlgitem (IDC_PAUSE_BUTTON) -> EnableWindow (TRUE);

Return True;

}

Return False;

}

转载请注明原文地址:https://www.9cbs.com/read-21867.html

New Post(0)