Exemplo n.º 1
0
        private void refreshAll()
        {
            m_bRefreshOver = false;
            Write("重新进行视频刷新操作!");

            try
            {
                close();
                clearList();

                HkAction.MainForm = this;
                m_bPlay           = HkAction.Start();//进入系统自动初始化库

                if (m_bPlay)
                {
                    Write("重新进行系统自动初始化库成功!");
                }

                playVedio();
            }
            catch (Exception ex)//出现异常则提示
            {
                m_strContent = "重新进行系统自动初始化库异常!" + ex.ToString();
                Write(m_strContent);
            }

            m_bRefreshOver = true;
        }
Exemplo n.º 2
0
        public IList <Camera> GetCamerasBy(int customerId)
        {
            List <Camera> cameraList = new List <Camera>();

            var httpServiceApi = new DataServiceApi();
            var request        = new RestRequest($"customer/videolist.json?customerId={customerId}", Method.GET);
            var cameraPartOne  = httpServiceApi.Execute <CameraPartOne>(request);

            var cameraPartTwoJson = HkAction.playList();
            var dto = JsonConvert.DeserializeObject <CameraPartTwo>(cameraPartTwoJson);

            if (dto != null)
            {
                foreach (var videoInfo in cameraPartOne.video)
                {
                    var cameraPartTwo = dto.cameras.FirstOrDefault(camera => camera.deviceSerial == videoInfo.videoSequence && camera.cameraNo.ToString() == videoInfo.videoChannel);
                    if (cameraPartTwo != null)
                    {
                        Camera camera = new Camera()
                        {
                            Id     = cameraPartTwo.cameraId,
                            Name   = videoInfo.videoName,
                            Status = cameraPartTwo.status
                        };
                        cameraList.Add(camera);
                    }
                }
            }
            return(cameraList);
        }
Exemplo n.º 3
0
        private void play()
        {
            try
            {
                createSessions();
                m_strContent = "播放视频";
                for (int i = 0; i < m_strCameraidList.Count; i++)
                {
                    m_bPlay       = HkAction.Play(handle[i], m_strCameraidList[i], m_SessionIdList[i]);
                    m_strContent += "(" + m_bPlay + "," + i + ")";
                }

                if (m_strCameraidList.Count <= 0)
                {
                    m_strContent += "失败!";
                }


                Write(m_strContent);
            }
            catch
            {
                m_strContent = "播放视频异常!";
                Write(m_strContent);
            }
        }
Exemplo n.º 4
0
 public CameraService()
 {
     if (HkAction.Start())
     {
         if (HkAction.GetAccessToken() != null)
         {
         }
     }
 }
Exemplo n.º 5
0
 public void StopAll()
 {
     foreach (var region in Regions)
     {
         if (region.IsDisplaying && region.SessionId != IntPtr.Zero)
         {
             HkAction.Stop(region.SessionId);
         }
     }
     SelectedIndex = 0;
 }
Exemplo n.º 6
0
        private void createSessions()
        {
            if (m_SessionIdList.Count > 0)
            {
                return;
            }

            for (int i = 0; i < m_strCameraidList.Count; i++)
            {
                m_SessionIdList.Add(HkAction.AllocSession());//申请会话,保存到列表中
            }
        }
Exemplo n.º 7
0
        private void playOne(int iIndex)
        {
            stopVedio();

            //重新开始播放
            try
            {
                HkAction.Play(handle[iIndex], m_strCameraidList[iIndex], m_SessionIdList[iIndex]);
            }
            catch
            {
            }
        }
Exemplo n.º 8
0
 private void Initialize()
 {
     try
     {
         if (HkAction.Start())
         {
             if (HkAction.GetAccessToken() != null)
             {
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 9
0
        private void regist()
        {
            //登陆
            try
            {
                if (HkAction.GetAccessToken() != null)
                {
                    m_strContent = "用户登录成功!";
                    Write(m_strContent);
                }
            }
            catch (Exception ex)
            {
                m_strContent = "用户登录异常!" + ex.ToString();
                Write(m_strContent);
            }

            //获取摄像头列表ID
            try
            {
                string getList = HkAction.playList();

                jsonHandle(getList);

                m_strContent = "获取摄像头列表ID";

                for (int i = 0; i < m_strCameraidList.Count; ++i)
                {
                    m_strContent += "(" + m_strCameraidList[i] + ")";
                }

                if (m_strCameraidList.Count <= 0)
                {
                    m_strContent += "失败!";
                }

                Write(m_strContent);
            }
            catch (Exception ex)//出现异常则提示
            {
                m_strContent = "获取摄像头列表ID!" + ex.ToString();
                Write(m_strContent);
            }
        }
Exemplo n.º 10
0
        public void Play(string cameraId)
        {
            var region = GetCurrentDisplayRegion();

            if (region.IsDisplaying && region.SessionId != IntPtr.Zero)
            {
                HkAction.Stop(region.SessionId);
            }
            region.SessionId = HkAction.AllocSession();
            if (region.SessionId != null && !string.IsNullOrEmpty(cameraId))
            {
                var playStatus = HkAction.Play(region.DisplayHandler, cameraId, region.SessionId);
                if (playStatus)
                {
                    region.IsDisplaying = true;
                    SelectedIndex       = SelectedIndex >= Regions.Count - 1 ? 0 : (SelectedIndex + 1);
                }
            }
        }
Exemplo n.º 11
0
        private void refresh()
        {
            m_strContent = "开始刷新视频!";
            Write(m_strContent);

            stopVedio();

            try
            {
                for (int i = 0; i < m_strCameraidList.Count; i++)
                {
                    HkAction.Play(handle[i], m_strCameraidList[i], m_SessionIdList[i]);
                }
            }
            catch (Exception ex)
            {
                m_strContent = "刷新视频异常!" + ex.ToString();
                Write(m_strContent);
            }
        }
Exemplo n.º 12
0
 public void stopVedio()
 {
     //停止所有播放
     foreach (IntPtr temp in m_SessionIdList)
     {
         try
         {
             m_bPlay = HkAction.Stop(temp);
             if (m_bPlay)
             {
                 m_strContent = "停止视频成功!";
                 Write(m_strContent);
             }
         }
         catch (Exception ex)
         {
             //MessageBox.Show("异常" + ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             m_strContent = "停止视频异常!" + ex.ToString();
             Write(m_strContent);
         }
     }
 }
Exemplo n.º 13
0
        private void VedioForm_Load(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    InitString();
                    Write(m_strContent);
                    HkAction.MainForm = this;
                    HkAction.Close();
                    m_bPlay = HkAction.Start();//进入系统自动初始化库
                    if (m_bPlay)
                    {
                        Write("系统自动初始化库成功。");
                    }
                }
                catch (Exception ex)//出现异常则提示
                {
                    //MessageBox.Show("异常!" + ex.ToString(), "提示", MessageBoxButtons.OK);
                    m_strContent = "系统自动初始化库异常!" + ex.ToString();
                    Write(m_strContent);
                }

                setControlLanguage();
                InitPictureBox();
                createThreadPlay();
                createTimer();

                m_formSize.Width  = this.Width;
                m_formSize.Height = this.Height;
                label1.Visible    = true;
                label1.BackColor  = Color.Transparent;
            }
            catch
            {
            }
        }
Exemplo n.º 14
0
        private void MakeRegions(int row, int columns)
        {
            int index = 0;

            for (int rowIndex = 0; rowIndex < row; rowIndex++)
            {
                for (int columnIndex = 0; columnIndex < columns; columnIndex++)
                {
                    if (Regions.Count < (row * columns))
                    {
                        if (Regions.Count <= index)
                        {
                            Regions.Add(new RegionInfo()
                            {
                                ColumnIndex = columnIndex, RowIndex = rowIndex, Index = index
                            });
                        }
                    }
                    else if (Regions.Count > (row * columns))
                    {
                        int isDisplayingCount = 0;
                        for (int iNum = 0; iNum < Regions.Count; iNum++)
                        {
                            if (Regions[iNum].IsDisplaying)
                            {
                                isDisplayingCount++;
                            }
                        }

                        if (isDisplayingCount > (row * columns))
                        {
                            for (int iNum = row * columns; iNum < Regions.Count; iNum++)
                            {
                                if (Regions[iNum].IsDisplaying && Regions[iNum].SessionId != IntPtr.Zero)
                                {
                                    HkAction.Stop(Regions[iNum].SessionId);
                                }
                            }
                            for (int iNum = Regions.Count; iNum > row * columns; iNum--)
                            {
                                Regions.RemoveAt(iNum - 1);
                            }
                        }
                        else
                        {
                            for (int iNum = Regions.Count; iNum > row * columns; iNum--)
                            {
                                Regions.RemoveAt(iNum - 1);
                            }
                        }
                        return;
                    }
                    else
                    {
                        return;
                    }

                    index++;
                }
            }
        }