C # video Surveillance series: H264 player-control playback and screenshots

Source: Internet
Author: User

First, control playback

1.1 Pause/Play/stop

VC + + Code:

////////////////////////////////////////////////////////////////////////////////
Funtion:play or change the play speed to normal;
///////////////////////////////////////////////////////////////////////////////
void Cplayerdlg::onplay ()
{
Todo:add your control notification handler code here
Play ();
}

void Cplayerdlg::P Lay ()
{
M_nspeed=0;
OnThrow0 ();
#ifdef _test_callback
if (M_bconvert)
Hik_playm4_setdeccallback (Port,deccbfun);
Else
M_pmainmenu->enablemenuitem (Id_file_close, FALSE);
#endif
if (m_bplaying)
{
Hik_playm4_play (Port,getdlgitem (idc_show)->m_hwnd);
}
Else
{
if (M_bstreamtype)
{
:: SetFilePointer (M_hstreamfile,m_nheadsize,0,file_begin);
Hik_playm4_resetsourcebuffer (PORT);
SetEvent (M_heventinput);
}
m_bplaying = Hik_playm4_play (Port,getdlgitem (idc_show)->m_hwnd);
M_bsound=hik_playm4_playsound (PORT);
if (m_bplaying)
SetTimer (Play_timer,500,null);

}
if (m_bplaying)

Setplaystate ();
Else
{
CString Cserror;
Cserror.format ("Play the" file Faild. %d) ", Hik_playm4_getlasterror (PORT));
AfxMessageBox (Cserror);
}

}
//////////////////////////////////////////////////////////////////////////////
Funtion:pause.
//////////////////////////////////////////////////////////////////////////////
void Cplayerdlg::onpause ()
{
Todo:add your control notification handler code here
if (m_bplaying)
{
M_bpause=!m_bpause;
Pause (M_bpause);
}
}
void Cplayerdlg::P ause (BOOL bpause)
{
if (m_bpaused = = Bpause)
Return
M_bpaused=bpause;
Hik_playm4_pause (Port,bpause);
TRACE ("PAUSE%d\n", m_bpaused);
}
/////////////////////////////////////////////////////////////////////////////
Function:stop
/////////////////////////////////////////////////////////////////////////////
void Cplayerdlg::onstop ()
{
Todo:add your control notification handler code here

if (m_bplaying)
{
Stop ();
}
if (M_bconvert)
{
if (outfile!=null)
Closewrifffiles ();
if (yuvbuf!=null)
{
Free (YUVBUF);
Yuvbuf=null;
}
m_bconvert=0;

//
}
}
void Cplayerdlg::stop ()
{
CButton *pbutton;
if (!m_bplaying)
Return
KillTimer (Play_timer);
if (Hik_playm4_stopsound ())
{
M_bsound=false;
Pbutton = (CButton *) GetDlgItem (idc_sound);
Pbutton->seticon (M_hsoundstopicon);
}
Continue before stop. Add by LGL at 9-19;
M_bpause=false;

Stop
M_bplaying =! Hik_playm4_stop (PORT);
if (!m_bplaying)
{
Setstopstate ();
if (M_bstreamtype)
ResetEvent (M_heventinput);
}

    
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.