Exemplo n.º 1
0
        /// <summary>
        /// Loads the shutter sound.
        /// </summary>
        /// <returns><c>true</c>, if shutter sound was loaded, <c>false</c> otherwise.</returns>
        private bool LoadShutterSound()
        {
            try
            {
                _mediaSound = new MediaActionSound();
                _mediaSound.LoadAsync(MediaActionSoundType.ShutterClick);

                return(true);
            }
            catch (Java.Lang.Exception error)
            {
                Log.WriteLine(LogPriority.Error, error.Source, error.Message);
            }

            return(false);
        }
        public void TakePhoto()
        {
            if (_context == null || CameraDevice == null)
            {
                return;
            }

            if (_captureBuilder == null)
            {
                _captureBuilder = CameraDevice.CreateCaptureRequest(CameraTemplate.StillCapture);
            }
            _captureBuilder.AddTarget(_imageReader.Surface);
            _captureBuilder.Set(CaptureRequest.ControlAfMode, (int)ControlAFMode.ContinuousPicture);
            SetAutoFlash(_captureBuilder);

            var windowManager = _context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>();
            int rotation      = (int)windowManager.DefaultDisplay.Rotation;
            int orientation   = GetOrientation(rotation);

            _captureBuilder.Set(CaptureRequest.JpegOrientation, orientation);

            _previewSession.StopRepeating();
            _previewSession.AbortCaptures();
            _previewSession.Capture(_captureBuilder.Build(),
                                    new CameraCaptureStillPictureSessionCallback
            {
                OnCaptureCompletedAction = session =>
                {
                    UnlockFocus();
                }
            }, null);
            // Play shutter sound to alert user that image was captured
            var am = (AudioManager)_context.GetSystemService(Context.AudioService);

            if (am != null && am.RingerMode == RingerMode.Normal)
            {
                var cameraSound = new MediaActionSound();
                cameraSound.Load(MediaActionSoundType.ShutterClick);
                cameraSound.Play(MediaActionSoundType.ShutterClick);
            }
        }
Exemplo n.º 3
0
        public void CaptureStillPicture()
        {
            try
            {
                if (null == cameraDevice)
                {
                    return;
                }

                // This is the CaptureRequest.Builder that we use to take a picture.
                var stillCaptureBuilder = cameraDevice.CreateCaptureRequest(CameraTemplate.StillCapture);

                stillCaptureBuilder.AddTarget(imageReader.Surface);

                // Use the same AE and AF modes as the preview.
                stillCaptureBuilder.Set(CaptureRequest.ControlAfMode, (int)ControlAFMode.ContinuousPicture);
                SetAutoFlash(stillCaptureBuilder);

                // Orientation
                int rotation    = (int)WindowManager.DefaultDisplay.Rotation;
                int orientation = GetOrientation(rotation);
                stillCaptureBuilder.Set(CaptureRequest.JpegOrientation, orientation);

                captureSession.StopRepeating();
                captureSession.AbortCaptures();
                captureSession.Capture(stillCaptureBuilder.Build(), cameraCaptureCallback, null);

                // Play shutter sound to alert user that image was captured
                var am = (AudioManager)GetSystemService(AudioService);
                if (am != null && am.RingerMode == RingerMode.Normal)
                {
                    var cameraSound = new MediaActionSound();
                    cameraSound.Load(MediaActionSoundType.ShutterClick);
                    cameraSound.Play(MediaActionSoundType.ShutterClick);
                }
            }
            catch (CameraAccessException e)
            {
                e.PrintStackTrace();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Loads the shutter sound.
        /// </summary>
        /// <returns><c>true</c>, if shutter sound was loaded, <c>false</c> otherwise.</returns>
        private bool LoadShutterSound()
        {
            try
            {
                _mediaSound = new MediaActionSound();
                _mediaSound.LoadAsync(MediaActionSoundType.ShutterClick);

                return(true);
            }
            catch (Java.Lang.Exception error)
            {
                _log.WriteLineTime(_tag + "\n" +
                                   "LoadShutterSound() Error loading shutter sound  \n " +
                                   "ErrorMessage: \n" +
                                   error.Message + "\n" +
                                   "Stacktrace: \n " +
                                   error.StackTrace);
            }

            return(false);
        }
Exemplo n.º 5
0
        private bool LoadShutterSound()
        {
            try
            {
                _mediaSound = new MediaActionSound();
                _mediaSound.LoadAsync(MediaActionSoundType.ShutterClick);

                return(true);
            }
            catch (Java.Lang.Exception error)
            {
                System.Diagnostics.Debug.WriteLine($"{error.Message} {error.StackTrace}");
                //                _log.WriteLineTime(_tag + "\n" +
                //                                   "LoadShutterSound() Error loading shutter sound  \n " +
                //                                   "ErrorMessage: \n" +
                //                                   error.Message + "\n" +
                //                                   "Stacktrace: \n " +
                //                                   error.StackTrace);
            }

            return(false);
        }
Exemplo n.º 6
0
        public override void OnCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result)
        {
            MediaActionSound shutterSound = new MediaActionSound();

            shutterSound.Play(MediaActionSoundType.ShutterClick);
        }