public bool Preview(IntPtr HWnd, Func <object, object> Callback) { if (this.cameraClient.lLogin > 0)//登录成功 { //3、启动实时监视或多画面预览(参数如何填写) //this.currentHandle = cameraClient.RealPlay(0, HWnd, 0, 0); this.currentHandle = cameraClient.RealPlay(this.cameraParameter.PreviewChannelID, HWnd, this.cameraParameter.StreamType, this.cameraParameter.NetType); this.isPlaying = this.currentHandle > 0; } if (Callback != null) { Callback(new object[] { this.currentHandle }); } return(this.isPlaying); }
/// <summary> /// 开启视频 /// </summary> /// <param name="camera"></param> /// <param name="hWnd"></param> /// <param name="errMsg"></param> private bool openVideo(CameraEquipment camera, IntPtr hWnd, out string errMsg) { errMsg = ""; if (myPlayHandle >= 0) { return(true); } //1、SDK初始化 CameraClient.Init(); if (cameraClient == null || cameraClient.lLogin < 0) { try { //2、登录网络设备 cameraClient = new CameraClient(); int error = cameraClient.Login(camera.IP, ushort.Parse(camera.Port.ToString()), camera.UserName, camera.PassWord, 0, ""); if (error > 0) { errMsg = "登录失败"; } } catch (Exception ex) { errMsg = "登录失败"; } } if (cameraClient.lLogin >= 0)//登录成功 { //3、启动实时监视或多画面预览(参数如何填写) myPlayHandle = cameraClient.RealPlay(1, hWnd, 0, 0); if (myPlayHandle >= 0) { videoShow = true; } else { videoShow = false; } } return(videoShow); }