public bool StartPlay(string cameraId) { if (_currSelectedBox != null) { PlayObject obj = _currSelectedBox.Tag as PlayObject; OnClosePlayBox(obj); IntPtr hwnd = _currSelectedBox.Handle; IntPtr sessionId = HkApi.AllocSession(); HkApi.StartPlay(hwnd, cameraId, sessionId); obj.IsPlaying = true; obj.SessionId = sessionId; obj.CameraId = cameraId; OnPlayingBox(_currSelectedBox); _currSelectedBox = null; } else { PictureBox box = GetIdleBox(); if (box != null) { PlayObject obj = box.Tag as PlayObject; IntPtr hwnd = box.Handle; IntPtr sessionId = HkApi.AllocSession(); HkApi.StartPlay(hwnd, cameraId, sessionId); obj.IsPlaying = true; obj.SessionId = sessionId; obj.CameraId = cameraId; OnPlayingBox(box); } } return(false); }
private void OnClosePlayBox(PlayObject obj) { if (obj.IsPlaying) { HkApi.StopPlay(obj.SessionId); obj.SessionId = IntPtr.Zero; obj.CameraId = string.Empty; obj.IsPlaying = false; } }
protected override void OnLoad(EventArgs e) { btn1.Click += Btn_Click; btn4.Click += Btn_Click; btn9.Click += Btn_Click; btn16.Click += Btn_Click; Btn_Click(btn4, EventArgs.Empty);//调用InitPlayBox,初始化界面,默认是4个播放页面; //PlayBoxClick(_listPlayBox[0], EventArgs.Empty); //默认选择第一个box; HkApi.Init(); }
/// <summary> /// 释放视频 /// </summary> public void DisposeCamera() { try { foreach (PictureBox box in _listPlayBox) { PlayObject obj = box.Tag as PlayObject; OnClosePlayBox(obj); } HkApi.Close(); } catch (Exception e) { Debug.WriteLine(e); } }
public HkApi.GetDevListResult GetCameraList() { return(HkApi.GetCameraList()); }
public string GetCameraList4JsonString() { return(HkApi.GetCameraList4Json()); }
public bool LoginByMid() { return(HkApi.Login()); }
//public PictureBox GetCurrSelectedBox //{ // get // { // return _currSelectedBox; // } //} public bool LoginImmediately() { return(HkApi.LoginImmediately()); }