public bool StopRemoteBackplayByTime()
 {
     //停止回放
     SDK_ZLNetSDK.ZLNET_StopPlayBack(lPlayHandle);
     DebugRelevant.DebugLog(this, "ZLNET_StopPlayBack");
     lPlayHandle = 0;
     //登出设备
     SDK_ZLNetSDK.ZLNET_Logout(m_nDeviceID);
     DebugRelevant.DebugLog(this, "ZLNET_Logout");
     m_nDeviceID = 0;
     PicPlayMain.Refresh();
     BackplayStatus = VideoRemoteBackplayStatus.StandBy;
     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);
        }
        public bool VideoPlay()
        {
            if (VideoPlayState == Enum_VideoPlayState.InPlayState)
            {
                VideoClose();
            }
            bool bolResult             = false;
            NET_DVR_DEVICEINFO_V30 dev = new NET_DVR_DEVICEINFO_V30();

            _intDVRHwd = NET_DVR_Login_V30(CurrentVideoInfo.DVSAddress, CurrentVideoInfo.DVSConnectPort, CurrentVideoInfo.UserName, CurrentVideoInfo.Password, ref dev);

            if (_intDVRHwd >= 0)
            {
                DebugRelevant.DebugLog(this, "Hik:设备登陆成功:" + CurrentVideoInfo.DVSAddress);
                DebugRelevant.DebugLog(this, "Hik:设备信息:" + JsonConvert.SerializeObject(dev));
                dwAChanTotalNum = (uint)dev.byChanNum;
                if (dev.byIPChanNum > 0)
                {
                    InfoIPChannel();
                }
                else
                {
                    for (iip = 0; iip < dwAChanTotalNum; iip++)
                    {
                        iChannelNum[iip] = iip + (int)dev.byStartChan;
                    }
                }

                for (int i = 0; i < iChannelNum.Length; i++)
                {
                    DebugRelevant.DebugLog(this, "Hik:设备通道信息:" + "Index[" + i + "]" + iChannelNum[i]);
                }

                NET_DVR_PREVIEWINFO lpPreviewInfo = new NET_DVR_PREVIEWINFO();
                lpPreviewInfo.hPlayWnd = intptrPlayMain;//预览窗口
                if (dev.byIPChanNum == 0)
                {
                    lpPreviewInfo.lChannel = CurrentCameraInfo.Channel;
                    //SaveNetLog("播放通道" + channel.ToString());
                }
                else
                {
                    lpPreviewInfo.lChannel = iChannelNum[CurrentCameraInfo.Channel - 1];
                }
                if (CurrentVideoPlaySet.PlayStream == Enum_VideoStream.MainStream)
                {
                    lpPreviewInfo.dwStreamType = 0;//码流类型:0-主码流,1-子码流,2-码流3,3-码流4,以此类推
                    videoStream = Enum_VideoStream.MainStream;
                }
                else
                {
                    lpPreviewInfo.dwStreamType = 1;//码流类型:0-主码流,1-子码流,2-码流3,3-码流4,以此类推
                    videoStream = Enum_VideoStream.SubStream;
                }
                lpPreviewInfo.dwLinkMode = 0;    //连接方式:0- TCP方式,1- UDP方式,2- 多播方式,3- RTP方式,4-RTP/RTSP,5-RSTP/HTTP
                lpPreviewInfo.bBlocked   = true; //0- 非阻塞取流,1- 阻塞取流


                //NET_DVR_CLIENTINFO cli = new NET_DVR_CLIENTINFO();
                //cli.lLinkMode = 0;// 设置连接方式  /*  最高位(31)为 0 表示主码流,为 1 表示子码流,0-30 位表示码流连接方式:0:TCP方式,1:UDP 方式,2:多播方式,3 - RTP方式,4—音视频分开 */
                //cli.lChannel = channel + 32;
                //cli.hPlayWnd = playHandle;

                // 开始播放视频
                //Thread.Sleep(50);



                DebugRelevant.DebugLog(this, "Hik:真实播放通道号:" + lpPreviewInfo.lChannel);
                IntPtr           pUser    = new IntPtr();
                REALDATACALLBACK RealData = new REALDATACALLBACK(RealDataCallBack);//预览实时流回调函数

                //intRet = NET_DVR_RealPlay_V30(_intDVRHwd, ref cli, null, pUser, 1);//130814
                intRet = NET_DVR_RealPlay_V40(_intDVRHwd, ref lpPreviewInfo, null, pUser);//140521


                if (intRet != -1)
                {
                    if (CurrentVideoPlaySet.VideoMonitorEnable)
                    {
                        OpenSound();
                    }
                    VideoPlayCallback(new VideoPlayCallbackValue {
                        evType = Enum_VideoPlayEventType.VideoPlay
                    });
                    VideoPlayState = Enum_VideoPlayState.InPlayState;
                    if (CurrentVideoPlaySet.VideoRecordEnable)
                    {
                        StartVideoRecord(CurrentVideoPlaySet.VideoRecordFilePath);
                    }
                }
                else
                {
                    VideoPlayCallback(new VideoPlayCallbackValue {
                        evType = Enum_VideoPlayEventType.VideoPlayException
                    });
                }
            }
            else
            {
                VideoPlayCallback(new VideoPlayCallbackValue {
                    evType = Enum_VideoPlayEventType.DevLoginException
                });
                //登陆失败
                bolResult = false;
            }



            return(bolResult);
        }