Exemplo n.º 1
0
        /// <summary>
        /// 开始预览视频(同时只能打开一个相机)
        /// </summary>
        /// <param name="cameraName"></param>
        public bool StartPreview(string cameraName)
        {
            try
            {
                bool    retVal = false;
                XCamera cam    = XCamera.GetInstance();
                if (cam.IsActive())
                {
                    if (cam.RunMode != emDSRunMode.RUNMODE_STOP)
                    {
                        cam.Stop();
                    }
                    cam.UnInit();
                }
                _cameraCallbackProc = new XCamera.DelegateProc(SnapThreadCallback);

                //test

                if (cam.Init(_cameraCallbackProc, cameraName, _imageBox.Handle))
                //if (cam.Init(_cameraCallbackProc, cameraName, _imageBack.Handle))
                {
                    if (cam.Play())
                    {
                        retVal = true;
                        //this.RealSize();
                        this.FitScreen();
                        PublishCameraOpenedEvent(new EventArgs());
                    }
                }
                else
                {
                    retVal = false;
                }
                return(retVal);
            }
            catch (System.Exception ex)
            {
                _logger.Error(ex.Message);
                return(false);
            }
        }