public TCPliuclient(string ip, int port, int tongdao, IntPtr Handle) { _tongdao = tongdao; receiveServerEvent += Tcp_receiveServerEvent;; start(ip, port); dhplay.DHPlayControl(PLAY_COMMAND.Start, tongdao, IntPtr.Zero, 0, (UInt32)900 * 1024); //播放的部分 bool b2 = dhplay.DHPlayControl(PLAY_COMMAND.OpenStream, tongdao, IntPtr.Zero, 0, 900 * 1024); dhplay.DHSetStreamOpenMode(tongdao, PLAY_MODE.STREAME_REALTIME); dhplay.DHPlayControl(0, tongdao, Handle); }
/// <summary> /// 慢放菜单处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mnuSlow_Click(object sender, EventArgs e) { if (!DHPlay.DHPlayControl(PLAY_COMMAND.Slow, 0)) { MessageBox.Show("慢放失败!", pMsgTitle); } }
/// <summary> /// 视频亮度 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void hsbBrightness_ValueChanged(object sender, EventArgs e) { mnuBrightnessUp.Enabled = (hsbBrightness.Value == hsbBrightness.Maximum ? false : true); mnuBrightnessDown.Enabled = (hsbBrightness.Value == 0 ? false : true); pColor.pBrightness = hsbBrightness.Value; DHPlay.DHPlayControl(PLAY_COMMAND.SetColor, 0, 0, ref pColor); }
private void btnTobegin_Click(object sender, EventArgs e) { if (playRecordFile > 0) { uint ppio = DHPlay.DHPlayControl(PLAY_COMMAND.ToBegin, 0, true); } }
private void timerGetPlayInfo_Tick(object sender, EventArgs e) { uint playedFrameNum = DHPlay.DHPlayControl(PLAY_COMMAND.GetCurrentFrameNum, 0, true); uint playedTime = DHPlay.DHPlayControl(PLAY_COMMAND.GetPlayedTime, 1, true); //f/s lblCurrentFrame.Text = Convert.ToString(playedFrameNum); //valor de trackbar + valor en segundos de los segundos transcurridos trbPlayFrames.Value = positionValue + secondsToTrbValue((int)playedTime, segundosTotales); // (*) El valor del trakbar se pasa a segundos segun la duracion del video int segundos = trbValueToSeconds(trbPlayFrames.Value, segundosTotales); //tiempo transcurrido orig lblCurrentTime.Text = DHPlay.DHConvertToTime(playedTime, 1, "HH:MM:SS"); //Se agrega el cálculo (*) al tiempo transcurrido DateTime timeAux = Convert.ToDateTime(lblCurrentTime.Text); timeAux = timeAux.AddSeconds(segundos); lblfechaaux.Text = timeAux.ToString("HH:mm:ss"); lblCurrentTime.Text = lblfechaaux.Text; }
/// <summary> /// 视频饱和度 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void hsbSaturation_ValueChanged(object sender, EventArgs e) { mnuSaturationDown.Enabled = (hsbSaturation.Value == 0 ? false : true); mnuSaturationUp.Enabled = (hsbSaturation.Value == hsbSaturation.Maximum ? false : true); pColor.pSaturation = hsbSaturation.Value; DHPlay.DHPlayControl(PLAY_COMMAND.SetColor, 0, 0, ref pColor); }
/// <summary> /// 视频色调 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void hsbHue_ValueChanged(object sender, EventArgs e) { mnuHueUp.Enabled = (hsbHue.Value == hsbHue.Maximum ? false : true); mnuHueDown.Enabled = (hsbHue.Value == 0 ? false : true); pColor.pHue = hsbHue.Value; DHPlay.DHPlayControl(PLAY_COMMAND.SetColor, 0, 0, ref pColor); }
private void trackBarVolume_ValueChanged(object sender, EventArgs e) { if (trackBarVolume.Minimum <= trackBarVolume.Value && trackBarVolume.Value <= trackBarVolume.Maximum) { DHPlay.DHPlayControl(PLAY_COMMAND.SetVolume, 0, (uint)trackBarVolume.Value); } }
private void btnSoundPlayBack_Click(object sender, EventArgs e) { if (btnSoundPlayBack.Tag.ToString() == "Off") { btnSoundPlayBack.Tag = "On"; DHPlay.DHPlayControl(PLAY_COMMAND.PlaySound, 0); int VolumenRep = (int)DHPlay.DHPlayControl(PLAY_COMMAND.GetVolume, 0, true); if (trackBarVolume.Minimum <= VolumenRep && VolumenRep <= trackBarVolume.Maximum) { trackBarVolume.Enabled = true; trackBarVolume.Value = VolumenRep; } else { trackBarVolume.Enabled = false; trackBarVolume.Value = VolumenRep; } btnSoundPlayBack.Image = global::bykomDahua.Properties.Resources.audio16x16; } else { btnSoundPlayBack.Tag = "Off"; DHPlay.DHPlayControl(PLAY_COMMAND.StopSound); trackBarVolume.Enabled = false; btnSoundPlayBack.Image = global::bykomDahua.Properties.Resources.audioOff16x16; } }
private void btnStopRealPlay_Click(object sender, EventArgs e) { DHPlay.DHPlayControl(PLAY_COMMAND.Stop, 0); DHPlay.DHPlayControl(PLAY_COMMAND.CloseStream, 0); btnStartRealPlay.Enabled = true; btnStopRealPlay.Enabled = false; picPlayMain.Refresh(); }
private void btnValPorDefecto_Click(object sender, EventArgs e) { pColor.pBrightness = 64; pColor.pContrast = 64; pColor.pSaturation = 64; pColor.pHue = 64; DHPlay.DHPlayControl(PLAY_COMMAND.SetColor, 0, 0, ref pColor); }
/// <summary> /// 继续播放菜单处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mnuResum_Click(object sender, EventArgs e) { if (DHPlay.DHPlayControl(PLAY_COMMAND.ReSume, 0)) { SetPauseResumControl(0); } else { MessageBox.Show("继续播放失败!", pMsgTitle); } }
///// <summary> ///// 重新让视频显示在PictureBox上 ///// </summary> public void ShowVidio() { try { DHPlay.DHPlayControl(PLAY_COMMAND.ReSume, _iChannel); } catch (Exception ex) { Log.WriteLog("大华视频显示控件-重新显示视频:", ex); } }
///// <summary> ///// 视频清除,但仍可抓图 ///// </summary> public void ClearVideo() { try { DHPlay.DHPlayControl(PLAY_COMMAND.Pause, _iChannel); } catch (Exception ex) { Log.WriteLog("大华视频显示控件-清除视频:", ex); } }
private void button1_Click(object sender, EventArgs e) { if (DHPlay.DHPlayControl(PLAY_COMMAND.ReSume, 0)) { btnPlay2.Tag = "||"; play2State(); } else { MessageBox.Show("Problema al ejecutar operación", "Error"); } }
/// <summary> /// 播放录像菜单处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mnuStart_Click(object sender, EventArgs e) { if (!DHPlay.DHPlayControl(PLAY_COMMAND.Start, 0, this.picPlayMain.Handle)) { MessageBox.Show("播放文件失败!", pMsgTitle); } else { SetPlayStopControl(1); chkEnableSound_CheckedChanged(sender, e);//处理声音开关6 } }
private void getAjustesVideo() { bool blnReturn = DHPlay.DHPlayControl(PLAY_COMMAND.GetColor, 0, (uint)picPlayMain.Handle, ref pColor); if (blnReturn) { hsbBrightness.Value = pColor.pBrightness; hsbContrast.Value = pColor.pContrast; hsbHue.Value = pColor.pHue; hsbSaturation.Value = pColor.pSaturation; } }
/// <summary> /// 单帧播放菜单处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mnuStepBack_Click(object sender, EventArgs e) { if (!DHPlay.DHPlayControl(PLAY_COMMAND.OneByOneBack, 0)) { MessageBox.Show("单帧播放失败!", pMsgTitle); } else { //播放/停止按钮为播放状态 SetPlayStopControl(3); } }
private void trbPlayFrames_MouseDown(object sender, MouseEventArgs e) { if (DHPlay.DHPlayControl(PLAY_COMMAND.Pause, 0)) { btnPlay2.Tag = ">"; timerGetPlayInfo.Stop(); timerGetPlayInfo.Enabled = false; } else { MessageBox.Show("Problema al ejecutar operación", "Error"); } }
private void btnOpenSound_Click(object sender, EventArgs e) { if (btnOpenSound.Tag.ToString() == "Off") { btnOpenSound.Image = global::bykomDahua.Properties.Resources.audio16x16; btnOpenSound.Tag = "On"; DHPlay.DHPlayControl(PLAY_COMMAND.PlaySound, 0); } else { btnOpenSound.Image = global::bykomDahua.Properties.Resources.audioOff16x16; btnOpenSound.Tag = "Off"; DHPlay.DHPlayControl(PLAY_COMMAND.StopSound); } }
/// <summary> /// 停止播放菜单处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mnuStop_Click(object sender, EventArgs e) { if (!DHPlay.DHPlayControl(PLAY_COMMAND.Stop, 0)) { MessageBox.Show("停止播放失败!", pMsgTitle); } else { SetPlayStopControl(0); trbPlayFrames.Value = 0; stlCurrentFrame.Text = "0"; stlCurrentTime.Text = "00:00:00"; this.picPlayMain.Refresh();//刷新画面 } }
private void procesoPlay2() { gFileInfo = nriFileInfo[lsvFiles.SelectedItems[0].Index]; pPlayBackChannelID = int.Parse(txtChannelID.Text.ToString()); fileInfo = gFileInfo; playRecordFile = DHClient.DHPlayBackByRecordFile(gLoginID, ref fileInfo, pictureBoxPlayback.Handle, null, IntPtr.Zero); if (playRecordFile == 0) { // MessageBox.Show("Ocurrió un error con al cargar la grabación", "Error"); btnCancelar_Click(null, null); playRecordFile = DHClient.DHPlayBackByRecordFile(gLoginID, ref fileInfo, pictureBoxPlayback.Handle, null, IntPtr.Zero); } if (playRecordFile > 0) { uint sizeFilecharge = fileInfo.size / 100; uint currentFrames = DHPlay.DHPlayControl(PLAY_COMMAND.GetCurrentFrameNum, 0, true); lblCurrentFrame.Text = currentFrames.ToString(); lblCurrentTime.Text = fileInfo.starttime.dwHour.ToString() + ":" + fileInfo.starttime.dwMinute.ToString() + ":" + fileInfo.starttime.dwSecond.ToString(); lblInfoVideo.Text = fileInfo.starttime.dwHour.ToString() + ":" + fileInfo.starttime.dwMinute.ToString() + ":" + fileInfo.starttime.dwSecond.ToString() + " - " + fileInfo.endtime.dwHour.ToString() + ":" + fileInfo.endtime.dwMinute.ToString() + ":" + fileInfo.endtime.dwSecond.ToString(); DateTime startTime = new DateTime(fileInfo.starttime.dwYear, fileInfo.starttime.dwMonth, fileInfo.starttime.dwDay, fileInfo.starttime.dwHour, fileInfo.starttime.dwMinute, fileInfo.starttime.dwSecond); DateTime endTime = new DateTime(fileInfo.endtime.dwYear, fileInfo.endtime.dwMonth, fileInfo.endtime.dwDay, fileInfo.endtime.dwHour, fileInfo.endtime.dwMinute, fileInfo.endtime.dwSecond); TimeSpan span = endTime.Subtract(startTime); segundosTotales = (int)span.TotalSeconds; lblTotalTime.Text = span.Hours.ToString() + ":" + span.Minutes.ToString() + ":" + span.Seconds.ToString(); trbPlayFrames.Maximum = 100;//(int) sizeFilecharge; timerGetPlayInfo.Enabled = true; btnPlay2.Tag = "||"; play2State(); gpbPlayBackControl.Enabled = true; } else { MessageBox.Show("Ocurrió un error con al cargar la grabación", "Error"); btnCancelar_Click(null, null); } }
/// <summary> /// 到最前帧播放菜单处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mnuToBegin_Click(object sender, EventArgs e) { if (!DHPlay.DHPlayControl(PLAY_COMMAND.ToBegin, 0)) { MessageBox.Show("定位到起始帧失败!", pMsgTitle); } else { if (mnuPause.Enabled) { mnuPause_Click(null, null); } trbPlayFrames.Value = 0; stlCurrentFrame.Text = "1"; } }
/// <summary> /// 到最后帧播放菜单处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mnuToEnd_Click(object sender, EventArgs e) { if (!DHPlay.DHPlayControl(PLAY_COMMAND.ToEnd, 0)) { MessageBox.Show("定位最后一帧失败!", pMsgTitle); } else { if (mnuPause.Enabled) { mnuPause_Click(null, null); } trbPlayFrames.Value = (trbPlayFrames.Maximum - 1 > 0?trbPlayFrames.Maximum - 1:0); stlCurrentFrame.Text = Convert.ToString((uint.Parse(stlTotalFrames.Text) - 1)); } }
/// <summary> /// 关闭录像文件菜单处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mnuCloseFile_Click(object sender, EventArgs e) { if (!DHPlay.DHPlayControl(PLAY_COMMAND.CloseFile, 0)) { MessageBox.Show("关闭文件失败!", pMsgTitle); } else { this.picPlayMain.Refresh();//刷新画面 if (mnuStop.Enabled) { mnuStop_Click(sender, e); } SetOpenCloseFileControl(0); } }
/// <summary> /// 音频允许设置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void chkEnableSound_CheckedChanged(object sender, EventArgs e) { if (chkEnableSound.Checked) { chkEnableSound.Image = imlMain.Images["AUDIO_ENABLE"]; DHPlay.DHPlayControl(PLAY_COMMAND.PlaySound, 0); } else { chkEnableSound.Image = imlMain.Images["AUDIO_DISABLE"]; DHPlay.DHPlayControl(PLAY_COMMAND.StopSound); } trbSound.Enabled = chkEnableSound.Checked; mnuSoundUp.Enabled = trbSound.Enabled; mnuSoundDown.Enabled = trbSound.Enabled; mnuSoundSwitch.Checked = chkEnableSound.Checked; mnuSoundSwitch.Image = chkEnableSound.Image; }
/// <summary> /// 画面时钟处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timerGetPlayInfo_Tick(object sender, EventArgs e) { if (pPlayVideoSizeMode != 9) { FRAME_INFO pFrameInfo = new FRAME_INFO(); uint totalFrames = DHPlay.DHPlayControl(PLAY_COMMAND.GetFileTotalFrames, 0, true); DHPlay.DHPlayControl(PLAY_COMMAND.GetPictureSize, 0, ref pFrameInfo); stlTotalFrames.Text = Convert.ToString(totalFrames); trbPlayFrames.Maximum = (int)(totalFrames > 0?totalFrames:0); int pParentHeight; int pParentWidth; if (palMain.Visible) { pParentWidth = palMain.Width; pParentHeight = palMain.Height; } else { pParentWidth = this.Width; pParentHeight = this.Height; } switch (pPlayVideoSizeMode) { case 0: //原始大小 picPlayMain.Width = pFrameInfo.nWidth; picPlayMain.Height = pFrameInfo.nHeight; picPlayMain.Top = (pParentHeight - picPlayMain.Height) / 2; picPlayMain.Left = (pParentWidth - picPlayMain.Width) / 2; break; case 1: //缩放 picPlayMain.Top = 0; picPlayMain.Height = pParentHeight; picPlayMain.Width = Convert.ToInt32(pFrameInfo.nWidth * ((float)pParentHeight / (float)pFrameInfo.nHeight)); picPlayMain.Left = (pParentWidth - picPlayMain.Width) / 2; break; } } SetPlayCurrentInfo(DHPlay.DHPlayControl(PLAY_COMMAND.GetCurrentFrameNum, 0, true), DHPlay.DHPlayControl(PLAY_COMMAND.GetPlayedTime, 0, true)); }
private void trbPlayFrames_MouseUp(object sender, MouseEventArgs e) { if (DHPlay.DHPlayControl(PLAY_COMMAND.ReSume, 0)) { btnPlay2.Tag = "||"; play2State(); } else { MessageBox.Show("Problema al ejecutar operación", "Error"); } if (!DHClient.DHPlayBackControl(playRecordFile, PLAY_CONTROL.SeekByBit, (uint)(trbPlayFrames.Value * (fileInfo.size / 100)))) { MessageBox.Show("Problema al ejecutar operación", "Error"); } positionValue = trbPlayFrames.Value; timerGetPlayInfo.Start(); timerGetPlayInfo.Enabled = true; }
/// <summary> /// 打开录像文件菜单处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mnuOpenFile_Click(object sender, EventArgs e) { if (ofdMain.ShowDialog() == DialogResult.OK) { if (DHPlay.DHPlayControl(PLAY_COMMAND.OpenFile, 0, ofdMain.FileName)) { SetOpenCloseFileControl(1); stlTotalTime.Text = DHPlay.DHConvertToTime(DHPlay.DHPlayControl(PLAY_COMMAND.GetFileTotalTime, 0, true), 1, "HH:mm:ss"); bool blnReturn = DHPlay.DHPlayControl(PLAY_COMMAND.GetColor, 0, (uint)picPlayMain.Handle, ref pColor); if (blnReturn) { hsbBrightness.Value = pColor.pBrightness; hsbContrast.Value = pColor.pContrast; hsbHue.Value = pColor.pHue; hsbSaturation.Value = pColor.pSaturation; } trbSound.Value = (int)DHPlay.DHPlayControl(PLAY_COMMAND.GetVolume, 0, true); } else { MessageBox.Show("打开文件失败!", pMsgTitle); } } }
/// <summary> /// 抓图菜单处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mnuCatchPic_Click(object sender, EventArgs e) { //保存图片目录未选择则须要选择一下保存路径 if (strSavePicPath.Length == 0) { if (fbdMain.ShowDialog() == DialogResult.OK) { strSavePicPath = fbdMain.SelectedPath; } else { return; } } //抓图处理代码 bool blnSavePic = false; string saveFilePath = strSavePicPath + @"\" + (DateTime.Now.ToString("yyyyMMdd_HHmmss")) + ".bmp"; blnSavePic = DHPlay.DHPlayControl(PLAY_COMMAND.CatchPic, 0, saveFilePath); if (!blnSavePic) { MessageBox.Show("保存图片失败!\n" + saveFilePath, pMsgTitle); } }