/// <summary> /// 远程 /// </summary> /// <param name="para"></param> /// <returns></returns> public bool StartRemoteBackplayByTime(VideoRemotePlayByTimePara para) { VideoInfo vInfo = para.CameraInfo.VideoInfo; CurrentVideoInfo = vInfo; CameraInfo cInfo = para.CameraInfo; CurrentCameraInfo = cInfo; if (m_lPlayHandle >= 0) { // 先停止播放 StopRemoteBackplayByTime(); } if (para.StartPlayTime > para.EndPlayTime) { return(false); } SDK_Hik.NET_DVR_DEVICEINFO_V30 DeviceInfo = new SDK_Hik.NET_DVR_DEVICEINFO_V30(); m_lUserID = SDK_Hik.NET_DVR_Login_V30(vInfo.DVSAddress, vInfo.DVSConnectPort, vInfo.UserName, vInfo.Password, ref DeviceInfo); uint uuu = SDK_Hik.NET_DVR_GetLastError(); if (m_lUserID < 0) { return(false); } int[] iChannelNum = SDK_Hik.GetChannel(m_lUserID, DeviceInfo); Console.WriteLine(DateTime.Now.ToString("HH:mm:ss") + "登陆成功"); SDK_Hik.NET_DVR_TIME Stime = SDK_Hik.ConvertToNetTime(para.StartPlayTime); SDK_Hik.NET_DVR_TIME Etime = SDK_Hik.ConvertToNetTime(para.EndPlayTime); int intChannel = Convert.ToInt32(cInfo.Channel); SDK_Hik.NET_DVR_VOD_PARA struVodPara = new SDK_Hik.NET_DVR_VOD_PARA(); struVodPara.dwSize = (uint)Marshal.SizeOf(struVodPara); struVodPara.struIDInfo.dwChannel = Convert.ToUInt32(iChannelNum[CurrentCameraInfo.Channel - 1]); //通道号 Channel number struVodPara.hWnd = IntPtrPlayMain;//回放窗口句柄 //设置回放的开始时间 Set the starting time to search video files struVodPara.struBeginTime = Stime; //设置回放的结束时间 Set the stopping time to search video files struVodPara.struEndTime = Etime; struVodPara.byStreamType = 1; m_lPlayHandle = SDK_Hik.NET_DVR_PlayBackByTime_V40(m_lUserID, ref struVodPara); if (m_lPlayHandle == -1) { return(false); } if (!SDK_Hik.NET_DVR_PlayBackControl(m_lPlayHandle, SDK_Hik.PlayBackControlCode.NET_DVR_PLAYSTART, 0, ref lpOutValue)) { return(false); } SDK_Hik.NET_DVR_PlayBackControl(m_lPlayHandle, SDK_Hik.PlayBackControlCode.NET_DVR_PLAYSTARTAUDIO, 0, ref lpOutValue); SDK_Hik.NET_DVR_PlayBackControl(m_lPlayHandle, SDK_Hik.PlayBackControlCode.NET_DVR_PLAYAUDIOVOLUME, 0XFFFF, ref lpOutValue); SDK_Hik.NET_DVR_PlayBackControl(m_lPlayHandle, SDK_Hik.PlayBackControlCode.NET_DVR_GETTOTALTIME, 0, ref totalTime); BackplayStatus = VideoRemoteBackplayStatus.RemoteBackplayByTimeStarted; return(true); }
private void BtnVideoPlay_Click(object sender, EventArgs e) { string strIP = txtIP.Text; int intPort = Convert.ToInt32(txtPort.Text); string strUserName = txtUserName.Text; string strPassword = txtPassword.Text; int intChannelCount = Convert.ToInt32(txtChannlNum.Text); VideoInfo v = new VideoInfo(); v.VideoType = Enum_VideoType.ZLVideo; v.DVSAddress = strIP; v.DVSChannelNum = 8; v.DVSConnectPort = 8000; v.DVSName = "海康DVR测试"; v.DVSNumber = "000501"; v.DVSType = "SK8605HA"; v.HostID = "0005"; v.UserName = strUserName; v.Password = strPassword; v.NetworkState = 0; for (int i = 1; i <= intChannelCount; i++) { CameraInfo c = new CameraInfo(); c.CameraName = "摄像头" + (i); c.Channel = i; c.DVSType = "SK8605HM"; c.DVSNumber = "000501"; c.VideoInfo = v; v.Cameras[c.Channel] = c; } int intChannel = Convert.ToInt32(txtChannel.Text); if (!v.Cameras.ContainsKey(intChannel)) { MessageBox.Show("通道号不存在"); return; } CameraInfo cInfo = v.Cameras[intChannel]; VideoRemotePlayByTimePara para = new VideoRemotePlayByTimePara { CameraInfo = cInfo, StartPlayTime = dtpStart.Value, EndPlayTime = dtpEnd.Value }; videoRemoteBackplayWindow1.StartRemoteBackplayByTime(para); }
private void BtnRemotePlayTime_Click(object sender, EventArgs e) { int intChannel = Convert.ToInt32(txtChannel.Text); if (!vInfo.Cameras.ContainsKey(intChannel)) { MessageBox.Show("通道不存在"); return; } CameraInfo cInfo = vInfo.Cameras[intChannel]; VideoRemotePlayByTimePara para = new VideoRemotePlayByTimePara { CameraInfo = cInfo, StartPlayTime = dtpStart.Value, EndPlayTime = dtpEnd.Value }; videoRemoteBackplayWindow1.StartRemoteBackplayByTime(para); }
/// <summary> /// 远程回放 /// </summary> /// <param name="para"></param> /// <returns></returns> public bool RemoteBackplayByTime(VideoRemotePlayByTimePara para) { return(false); }
public bool StartRemoteBackplayByTime(VideoRemotePlayByTimePara para) { if (lPlayHandle > 0) { SDK_ZLNetSDK.ZLNET_StopPlayBack(lPlayHandle); lPlayHandle = 0; PicPlayMain.Refresh(); } VideoInfo vInfo = para.CameraInfo.VideoInfo; CameraInfo cInfo = para.CameraInfo; if (CurrentVideoInfo != null && CurrentVideoInfo.VideoServerIP == para.CameraInfo.VideoInfo.VideoServerIP && CurrentVideoInfo.DVSConnectPort == para.CameraInfo.VideoInfo.DVSConnectPort && m_nDeviceID > 0) { //表示与前一次预览是同一台视频 并且登陆成功 不在重复进行登陆操作 CurrentVideoInfo = vInfo; CurrentCameraInfo = cInfo; DebugRelevant.DebugLog(this, "相同设备,并且登陆成功,不重复登陆"); } else { if (m_nDeviceID > 0) { SDK_ZLNetSDK.ZLNET_Logout(m_nDeviceID); DebugRelevant.DebugLog(this, "ZLNET_Logout"); m_nDeviceID = 0; } CurrentVideoInfo = vInfo; CurrentCameraInfo = cInfo; //登陆设备 int err = 0; SDK_ZLNetSDK.ZLNET_DEVICEINFO zlDevice = new SDK_ZLNetSDK.ZLNET_DEVICEINFO(); m_nDeviceID = SDK_ZLNetSDK.ZLNET_LoginEx(CurrentVideoInfo.DVSAddress, Convert.ToUInt16(CurrentVideoInfo.DVSConnectPort), CurrentVideoInfo.UserName, CurrentVideoInfo.Password, 0, (IntPtr)0, ref zlDevice, ref err); if (m_nDeviceID == 0) { DebugRelevant.DebugLog(this, "ZLNET_LoginEx Excepion,error:" + err); return(false); } DebugRelevant.DebugLog(this, "ZLNET_LoginEx Sueecss"); } //调用按照时间回放接口 //ZLNET_PlayBackByTimeV3 SDK_ZLNetSDK.ZLNET_PLAY_BY_TIME_PARAM sdkpara = new SDK_ZLNetSDK.ZLNET_PLAY_BY_TIME_PARAM { nChannel = CurrentCameraInfo.Channel - 1, tmStart = SDK_ZLNetSDK.ConvertToNetTime(para.StartPlayTime), tmEnd = SDK_ZLNetSDK.ConvertToNetTime(para.EndPlayTime), hWnd = IntPtrPlayMain, nStreamType = 2, nMediaFlag = 0, }; downLoadPosCallBack = new SDK_ZLNetSDK.fZLDownLoadPosCallBack(DownLoadPosCallBack); dataCallback = new SDK_ZLNetSDK.fZLDataCallBack(DataCallback); IntPtr iPosUser = Marshal.StringToHGlobalAnsi("iPosUser"); IntPtr iData = Marshal.StringToHGlobalAnsi("iData"); lPlayHandle = SDK_ZLNetSDK.ZLNET_PlayBackByTimeV3(m_nDeviceID, ref sdkpara, downLoadPosCallBack, iPosUser, dataCallback, iData); if (lPlayHandle == 0) { SDK_ZLNetSDK.ZLNET_Logout(m_nDeviceID); m_nDeviceID = 0; UInt32 erroe = SDK_ZLNetSDK.ZLNET_GetLastError(); DebugRelevant.DebugLog(this, "ZLNET_PlayBackByTimeV3 Exception,error:" + erroe); return(false); } DebugRelevant.DebugLog(this, "ZLNET_PlayBackByTimeV3 Success"); BackplayStatus = VideoRemoteBackplayStatus.RemoteBackplayByTimeStarted; //回放控制 return(false); }