示例#1
0
        /// <summary>
        /// Returns current camera frame. To use this method camera must be in capturing state.
        /// </summary>
        /// <param name="captureElement"></param>
        /// <returns></returns>
        public async Task <VideoFrame> GetPreviewFrameAsync()
        {
            IsStreaming.CheckIfFulfills("Camera", "streaming", true);

            try
            {
                return(await mediaCapture.GetPreviewFrameAsync());
            }
            catch (Exception ex)
            {
                CleanUp();
                throw new Exception($"Camera could not get preview frame: { ex.Message }. { Logger.GetExceptionLocalization(this) }");
            }
        }
示例#2
0
        /// <summary>
        /// Stops previewing to capture element. To use this method camera needs to be in capturing state.
        /// </summary>
        /// <returns></returns>
        public async Task StopPreviewAsync()
        {
            IsStreaming.CheckIfFulfills("Camera", "streaming", true);
            CleanCaptureElement();

            try
            {
                await mediaCapture.StopPreviewAsync();
            }
            catch (Exception ex)
            {
                CleanUp();
                throw new Exception($"Camera could not stop previewing: { ex.Message }. { Logger.GetExceptionLocalization(this) }");
            }
        }
示例#3
0
        /// <summary>
        /// Starts previewing video in capture element. To use this method camera mustn't be in capturing state.
        /// </summary>
        /// <param name="captureElement"></param>
        /// <returns></returns>
        public async Task StartPreviewAsync(CaptureElement captureElement)
        {
            IsStreaming.CheckIfFulfills("Camera", "streaming", false);
            isInitialized.CheckIfFulfills("Camera", "initialized", true);
            captureElement.Source = mediaCapture;

            try
            {
                await mediaCapture.StartPreviewAsync();
            }
            catch (Exception ex)
            {
                CleanUp();
                throw new Exception($"Camera could not start previewing: { ex.Message }. { Logger.GetExceptionLocalization(this) }");
            }
        }