代碼說明:
1.關於變量PORT、m_strPlayFileName和方法OpenFile可以看上篇文章的代碼。
2.注意Hik_PlayM4_Pause的第二個參數用法。
1.2 快進/慢進
VC++ Code:
//////////////////////////////////////////////////////////////////////////////
//Funtion: Fast
//////////////////////////////////////////////////////////////////////////////
void CPlayerDlg::OnFastForward()
{
// TODO: Add your control notification handler code here
//Throw B-Frame ,improve the performance;
if(Hik_PlayM4_Fast(PORT))
{
m_nSpeed++;
if(m_nSpeed>0)
OnThrow2();
SetFastForwardState();
}
}
//////////////////////////////////////////////////////////////////////////////
//Funtion: Slow;
//////////////////////////////////////////////////////////////////////////////
void CPlayerDlg::OnFastBackward()
{
// TODO: Add your control notification handler code here
if(Hik_PlayM4_Slow(PORT))
{
m_nSpeed--;
if(m_nSpeed<=0)
OnThrow0();
SetFastBackWardState();
}
}
C# Code:
int m_nSpeed;
/// <summary>
/// 快進
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnFastForward_Click(object sender, EventArgs e)
{
if (HikPlayer.Hik_PlayM4_Fast(PORT))
{
m_nSpeed++;
if (m_nSpeed > 0)
OnThrow2();
}
}
/// <summary>
/// 慢放
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnFastBackward_Click(object sender, EventArgs e)
{
//慢速播放
if (HikPlayer.Hik_PlayM4_Slow(PORT))
{
//timer1.Interval
m_nSpeed--;
if (m_nSpeed <= 0)
OnThrow0();
}
}
public void OnThrow0()
{
HikPlayer.Hik_PlayM4_ThrowBFrameNum(PORT, 0);
}
public void OnThrow2()
{
HikPlayer.Hik_PlayM4_ThrowBFrameNum(PORT, 2);
}