Class SimpleCameraHost

  • All Implemented Interfaces:
    android.hardware.Camera.AutoFocusCallback , com.commonsware.cwac.camera.CameraHost

    
    public class SimpleCameraHost
     implements CameraHost
                        
    • Constructor Detail

      • SimpleCameraHost

        SimpleCameraHost(Context _ctxt)
    • Method Detail

      • adjustPreviewParameters

         Camera.Parameters adjustPreviewParameters(Camera.Parameters parameters)

        Implement this to configure the Camera.Parameters for the purposes of the preview. Note that you will have another chance to configure the Camera.Parameters for a specific photo via adjustPictureParameters().

        Parameters:
        parameters - the Camera.
      • configureRecorderAudio

         void configureRecorderAudio(int cameraId, MediaRecorder recorder)

        This will be called by the library to give you a chance to configure the audio of the MediaRecorder, just prior to beginning to record a video. Please ONLY configure audio here.

        Parameters:
        cameraId - the camera that will be used for recording
        recorder - the MediaRecorder to be configured
      • configureRecorderOutput

         void configureRecorderOutput(int cameraId, MediaRecorder recorder)

        This will be called by the library to give you a chance to configure the output of the MediaRecorder, just prior to beginning to record a video. Please ONLY configure output here.

        Parameters:
        cameraId - the camera that will be used for recording
        recorder - the MediaRecorder to be configured
      • configureRecorderProfile

         void configureRecorderProfile(int cameraId, MediaRecorder recorder)

        This will be called by the library to give you a chance to configure the profile of the MediaRecorder, just prior to beginning to record a video. Please ONLY configure profile here.

        Parameters:
        cameraId - the camera that will be used for recording
        recorder - the MediaRecorder to be configured
      • getPreviewSize

         Camera.Size getPreviewSize(int displayOrientation, int width, int height, Camera.Parameters parameters)

        Called to allow you to indicate what size preview should be used

        Parameters:
        displayOrientation - orientation of the display in degrees
        width - width of the available preview space
        height - height of the available preview space
        parameters - the current camera parameters
      • getPreferredPreviewSizeForVideo

         Camera.Size getPreferredPreviewSizeForVideo(int displayOrientation, int width, int height, Camera.Parameters parameters, Camera.Size deviceHint)

        Same as getPreviewSize(), but called when we anticipate taking videos, as some devices may work better with lower-resolution previews, to reduce CPU load

        Parameters:
        displayOrientation - orientation of the display in degrees
        width - width of the available preview space
        height - height of the available preview space
        parameters - the current camera parameters
        deviceHint - the size that the device itself thinks should be used for video, which sometimes is ridiculously low
      • handleException

         void handleException(Exception e)

        Called when something blows up in CameraView, to allow you to alert the user as you see fit

        Parameters:
        e - an Exception indicating what went wrong
      • saveImage

         void saveImage(PictureTransaction xact, Bitmap bitmap)

        Called when a picture has been taken. This will be called on a background thread.

        Parameters:
        bitmap - Bitmap of the picture
      • saveImage

         void saveImage(PictureTransaction xact, Array<byte> image, int imageOrientation)

        Called when a picture has been taken. This will be called on a background thread. passes image orientation

        Parameters:
        image - byte array of the picture data (e.g.
      • autoFocusAvailable

         void autoFocusAvailable()

        This will be called by the library to let you know that auto-focus is available for your use, so you can update your UI accordingly.

      • autoFocusUnavailable

         void autoFocusUnavailable()

        This will be called by the library to let you know that auto-focus is not available for your use, so you can update your UI accordingly.

      • onCameraFail

         void onCameraFail(CameraHost.FailureReason reason)

        Called when we failed to open the camera for one reason or another, so you can let the user know

        Parameters:
        reason - a FailureReason indicating what went wrong