public bool StartRecord1(CameraEquipment camera, IntPtr hWnd, String filePath, out string errMsg) { errMsg = ""; //1、SDK初始化 CameraClient.Init(); if (cameraClient == null || cameraClient.lLogin < 0) { //2、登录网络设备 cameraClient = new CameraClient(); int error = cameraClient.Login(camera.IP, ushort.Parse(camera.Port.ToString()), camera.UserName, camera.PassWord, 0, ""); if (error > 0) { errMsg = "登录失败"; } } if (cameraClient.lLogin > 0)//登录成功 { //FileHelper.CreateDirByFile(filePath); //3、启动实时监视或多画面预览(参数如何填写) myPlayHandle = cameraClient.RealPlay(1, hWnd, 0, 0); if (myPlayHandle >= 0) { videoRecord = cameraClient.StartRecord(myPlayHandle, filePath); } } return(videoRecord); }
/// <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); }