android.media.MediaActionSound Java Examples

The following examples show how to use android.media.MediaActionSound. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CameraView.java    From Lassi-Android with MIT License 6 votes vote down vote up
@Override
public void dispatchOnFocusEnd(@Nullable final Gesture gesture, final boolean success,
                               @NonNull final PointF point) {
    mLogger.i("dispatchOnFocusEnd", gesture, success, point);
    mUiHandler.post(new Runnable() {
        @Override
        public void run() {
            if (success && mPlaySounds) {
                //noinspection all
                playSound(MediaActionSound.FOCUS_COMPLETE);
            }

            if (gesture != null && mGestureMap.get(gesture) == GestureAction.FOCUS_WITH_MARKER) {
                mTapGestureLayout.onFocusEnd(success);
            }

            for (CameraListener listener : mListeners) {
                listener.onFocusEnd(success, point);
            }
        }
    });
}
 
Example #2
Source File: MainActivity.java    From arcgis-runtime-samples-android with Apache License 2.0 6 votes vote down vote up
/**
 * capture the map as an image
 */
private void captureScreenshotAsync() {

  // export the image from the mMapView
  final ListenableFuture<Bitmap> export = mMapView.exportImageAsync();
  export.addDoneListener(new Runnable() {
    @Override
    public void run() {
      try {
        Bitmap currentMapImage = export.get();
        // play the camera shutter sound
        MediaActionSound sound = new MediaActionSound();
        sound.play(MediaActionSound.SHUTTER_CLICK);
        Log.d(TAG, "Captured the image!!");
        // save the exported bitmap to an image file
        SaveImageTask saveImageTask = new SaveImageTask();
        saveImageTask.execute(currentMapImage);
      } catch (Exception e) {
        Toast
            .makeText(getApplicationContext(), getResources().getString(R.string.map_export_failure) + e.getMessage(),
                Toast.LENGTH_SHORT).show();
        Log.e(TAG, getResources().getString(R.string.map_export_failure) + e.getMessage());
      }
    }
  });
}
 
Example #3
Source File: VideoFragment.java    From RPiCameraViewer with MIT License 6 votes vote down vote up
private void takeSnapshot()
{
	// get the snapshot image
	Bitmap image = textureView.getBitmap();

	// save the image
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss");
	String name = camera.network + "_" + camera.name.replaceAll("\\s+", "") + "_" + sdf.format(new Date()) + ".jpg";
	Utils.saveImage(getActivity().getContentResolver(), image, name, null);
	Log.info("takeSnapshot: " + name);

	// play the shutter sound
	MediaActionSound sound = new MediaActionSound();
	sound.play(MediaActionSound.SHUTTER_CLICK);

	// display a message
	String msg = String.format(getString(R.string.image_saved), getString(R.string.app_name));
	Toast toast = Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT);
	toast.show();
}
 
Example #4
Source File: RecordButton.java    From sandriosCamera with MIT License 6 votes vote down vote up
@Override
public void onClick(View view) {
    if (System.currentTimeMillis() - lastClickTime < CLICK_DELAY) {
        return;
    } else lastClickTime = System.currentTimeMillis();

    if (Build.VERSION.SDK_INT > 15) {
        MediaActionSound sound = new MediaActionSound();
        if (TAKE_PHOTO_STATE == currentState) {
            takePhoto(sound);
        } else if (READY_FOR_RECORD_STATE == currentState) {
            startRecording(sound);
        } else if (RECORD_IN_PROGRESS_STATE == currentState) {
            stopRecording(sound);
        }
    } else {
        if (TAKE_PHOTO_STATE == currentState) {
            takePhoto();
        } else if (READY_FOR_RECORD_STATE == currentState) {
            startRecording();
        } else if (RECORD_IN_PROGRESS_STATE == currentState) {
            stopRecording();
        }
    }
    setIcon();
}
 
Example #5
Source File: AndroidCamera2AgentImpl.java    From Camera2 with Apache License 2.0 6 votes vote down vote up
AndroidCamera2AgentImpl(Context context) {
    mCameraHandlerThread = new HandlerThread("Camera2 Handler Thread");
    mCameraHandlerThread.start();
    mCameraHandler = new Camera2Handler(mCameraHandlerThread.getLooper());
    mExceptionHandler = new CameraExceptionHandler(mCameraHandler);
    mCameraState = new AndroidCamera2StateHolder();
    mDispatchThread = new DispatchThread(mCameraHandler, mCameraHandlerThread);
    mDispatchThread.start();
    mCameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
    mNoisemaker = new MediaActionSound();
    mNoisemaker.load(MediaActionSound.SHUTTER_CLICK);

    mNumCameraDevices = 0;
    mCameraDevices = new ArrayList<String>();
    updateCameraDevices();
}
 
Example #6
Source File: ResourceCaptureToolsImpl.java    From Camera2 with Apache License 2.0 6 votes vote down vote up
private ResourceCaptureToolsImpl(
        RefCountBase<ResourceConstructed> resourceConstructed,
        RefCountBase<ResourceSurfaceTexture> resourceSurfaceTexture,
        RefCountBase<ResourceOpenedCamera> resourceOpenedCamera,
        CaptureSessionManager captureSessionManager,
        FocusController focusController,
        HeadingSensor headingSensor,
        SoundPlayer soundPlayer,
        MediaActionSound mediaActionSound)
{
    mResourceConstructed = resourceConstructed;
    mResourceConstructed.addRef();     // Will be balanced in close().
    mResourceSurfaceTexture = resourceSurfaceTexture;
    mResourceSurfaceTexture.addRef();  // Will be balanced in close().
    mResourceOpenedCamera = resourceOpenedCamera;
    mResourceOpenedCamera.addRef();    // Will be balanced in close().
    mCaptureSessionManager = captureSessionManager;
    mHeadingSensor = headingSensor;
    mHeadingSensor.activate();  // Will be balanced in close().
    mSoundPlayer = soundPlayer;
    mSoundPlayer.loadSound(R.raw.timer_final_second);  // Will be balanced in close().
    mSoundPlayer.loadSound(R.raw.timer_increment);     // Will be balanced in close().
    mMediaActionSound = mediaActionSound;
    mFocusController = focusController;
}
 
Example #7
Source File: ResourceCaptureToolsImpl.java    From Camera2 with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a reference counted {@link ResourceCaptureToolsImpl} object.
 */
public static RefCountBase<ResourceCaptureTools> create(
        RefCountBase<ResourceConstructed> resourceConstructed,
        RefCountBase<ResourceSurfaceTexture> resourceSurfaceTexture,
        RefCountBase<ResourceOpenedCamera> resourceOpenedCamera)
{
    CaptureSessionManager captureSessionManager = new CaptureSessionManagerImpl(
            new CaptureIntentSessionFactory(),
            SessionStorageManagerImpl.create(resourceConstructed.get().getContext()),
            resourceConstructed.get().getMainThread());
    HeadingSensor headingSensor =
            new HeadingSensor(AndroidServices.instance().provideSensorManager());
    SoundPlayer soundPlayer = new SoundPlayer(resourceConstructed.get().getContext());
    FocusSound focusSound = new FocusSound(soundPlayer, R.raw.material_camera_focus);
    FocusController focusController = new FocusController(
            resourceConstructed.get().getModuleUI().getFocusRing(),
            focusSound,
            resourceConstructed.get().getMainThread());
    MediaActionSound mediaActionSound = new MediaActionSound();
    ResourceCaptureTools resourceCaptureTools = new ResourceCaptureToolsImpl(
            resourceConstructed, resourceSurfaceTexture, resourceOpenedCamera,
            captureSessionManager, focusController, headingSensor, soundPlayer,
            mediaActionSound);
    return new RefCountBase<>(resourceCaptureTools);
}
 
Example #8
Source File: BaseAnncaFragment.java    From phoenix with Apache License 2.0 5 votes vote down vote up
protected void startRecording(@Nullable String directoryPath, @Nullable String fileName) {
    if (Build.VERSION.SDK_INT > MIN_VERSION_ICECREAM) {
        new MediaActionSound().play(MediaActionSound.START_VIDEO_RECORDING);
    }

    setRecordState(Record.RECORD_IN_PROGRESS_STATE);
    this.cameraController.startVideoRecord(directoryPath, fileName);

    if (cameraFragmentStateListener != null) {
        cameraFragmentStateListener.onRecordStateVideoInProgress();
    }
}
 
Example #9
Source File: CameraView.java    From Lassi-Android with MIT License 5 votes vote down vote up
@Override
public void onShutter(boolean shouldPlaySound) {
    if (shouldPlaySound && mPlaySounds) {
        //noinspection all
        playSound(MediaActionSound.SHUTTER_CLICK);
    }
}
 
Example #10
Source File: DocumentScannerFragment.java    From CVScanner with GNU General Public License v3.0 5 votes vote down vote up
void takePicture(){
    if(mCameraSource != null){
        mCameraSource.takePicture(new CameraSource.ShutterCallback() {
            @Override
            public void onShutter() {
                sound.play(MediaActionSound.SHUTTER_CLICK);
            }
        }, new CameraSource.PictureCallback() {
            @Override
            public void onPictureTaken(byte[] data) {
                detectDocumentManually(data);
            }
        });
    }
}
 
Example #11
Source File: OpenNoteCameraView.java    From react-native-documentscanner-android with MIT License 5 votes vote down vote up
public void blinkScreenAndShutterSound(){
    AudioManager audio = (AudioManager) mActivity.getSystemService(Context.AUDIO_SERVICE);
    switch( audio.getRingerMode() ){
        case AudioManager.RINGER_MODE_NORMAL:
            MediaActionSound sound = new MediaActionSound();
            sound.play(MediaActionSound.SHUTTER_CLICK);
            break;
        case AudioManager.RINGER_MODE_SILENT:
            break;
        case AudioManager.RINGER_MODE_VIBRATE:
            break;
    }
}
 
Example #12
Source File: BaseAnncaFragment.java    From phoenix with Apache License 2.0 5 votes vote down vote up
protected void stopRecording(CameraFragmentResultListener callback) {
    if (Build.VERSION.SDK_INT > MIN_VERSION_ICECREAM) {
        new MediaActionSound().play(MediaActionSound.STOP_VIDEO_RECORDING);
    }

    setRecordState(Record.READY_FOR_RECORD_STATE);
    this.cameraController.stopVideoRecord(callback);

    this.onStopVideoRecord(callback);

    if (cameraFragmentStateListener != null) {
        cameraFragmentStateListener.onRecordStateVideoReadyForRecord();
    }
}
 
Example #13
Source File: OneCameraZslImpl.java    From Camera2 with Apache License 2.0 5 votes vote down vote up
private void onShutterInvokeUI(final PhotoCaptureParameters params)
{
    // Tell CaptureModule shutter has occurred so it can flash the screen.
    params.callback.onQuickExpose();
    // Play shutter click sound.
    mMediaActionSound.play(MediaActionSound.SHUTTER_CLICK);
}
 
Example #14
Source File: BaseAnncaFragment.java    From phoenix with Apache License 2.0 5 votes vote down vote up
protected void takePhoto(CameraFragmentResultListener callback, @Nullable String directoryPath, @Nullable String fileName) {
    if (Build.VERSION.SDK_INT > MIN_VERSION_ICECREAM) {
        new MediaActionSound().play(MediaActionSound.SHUTTER_CLICK);
    }
    setRecordState(Record.TAKE_PHOTO_STATE);
    this.cameraController.takePhoto(callback, directoryPath, fileName);
    if (cameraFragmentStateListener != null) {
        cameraFragmentStateListener.onRecordStatePhoto();
    }
}
 
Example #15
Source File: CameraFragment.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Override
public void takePicture(@Nullable String directoryPath, @Nullable String fileName, OnCameraResultListener callback) {
    if (Build.VERSION.SDK_INT > MIN_VERSION_ICECREAM) {
        new MediaActionSound().play(MediaActionSound.SHUTTER_CLICK);
    }
    setRecordState(Record.TAKE_PHOTO_STATE);
    this.mCameraLifecycle.takePhoto(callback, directoryPath, fileName);
    if (mCameraStateListener != null) {
        mCameraStateListener.onRecordStatePhoto();
    }
}
 
Example #16
Source File: CaptureModule.java    From Camera2 with Apache License 2.0 5 votes vote down vote up
@Override
public void onQuickExpose()
{
    mMainThread.execute(new Runnable()
    {
        @Override
        public void run()
        {
            // Starts the short version of the capture animation UI.
            mAppController.startFlashAnimation(true);
            mMediaActionSound.play(MediaActionSound.SHUTTER_CLICK);
        }
    });
}
 
Example #17
Source File: AndroidCamera2AgentImpl.java    From Camera2 with Apache License 2.0 4 votes vote down vote up
@Override
public void takePicture(final Handler handler,
                        final CameraShutterCallback shutter,
                        CameraPictureCallback raw,
                        CameraPictureCallback postview,
                        final CameraPictureCallback jpeg) {
    // TODO: We never call raw or postview
    final CaptureAvailableListener picListener =
            new CaptureAvailableListener() {
        @Override
        public void onCaptureStarted(CameraCaptureSession session, CaptureRequest request,
                                     long timestamp, long frameNumber) {
            if (shutter != null) {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        if (mShutterSoundEnabled) {
                            mNoisemaker.play(MediaActionSound.SHUTTER_CLICK);
                        }
                        shutter.onShutter(AndroidCamera2ProxyImpl.this);
                    }});
            }
        }

        @Override
        public void onImageAvailable(ImageReader reader) {
            try (Image image = reader.acquireNextImage()) {
                if (jpeg != null) {
                    ByteBuffer buffer = image.getPlanes()[0].getBuffer();
                    final byte[] pixels = new byte[buffer.remaining()];
                    buffer.get(pixels);
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            jpeg.onPictureTaken(pixels, AndroidCamera2ProxyImpl.this);
                        }});
                }
            }
        }};
    try {
        mDispatchThread.runJob(new Runnable() {
            @Override
            public void run() {
                // Wait until PREVIEW_ACTIVE or better
                mCameraState.waitForStates(
                        ~(AndroidCamera2StateHolder.CAMERA_PREVIEW_ACTIVE - 1));
                mCameraHandler.obtainMessage(CameraActions.CAPTURE_PHOTO, picListener)
                        .sendToTarget();
            }
        });
    } catch (RuntimeException ex) {
        mCameraAgent.getCameraExceptionHandler().onDispatchThreadException(ex);
    }
}
 
Example #18
Source File: CaptureModule.java    From Camera2 with Apache License 2.0 4 votes vote down vote up
@Override
public void init(CameraActivity activity, boolean isSecureCamera, boolean isCaptureIntent)
{
    Profile guard = mProfiler.create("CaptureModule.init").start();
    Log.d(TAG, "init UseAutotransformUiLayout = " + USE_AUTOTRANSFORM_UI_LAYOUT);
    HandlerThread thread = new HandlerThread("CaptureModule.mCameraHandler");
    thread.start();
    mCameraHandler = new Handler(thread.getLooper());
    mOneCameraOpener = mAppController.getCameraOpener();

    try
    {
        mOneCameraManager = OneCameraModule.provideOneCameraManager();
    } catch (OneCameraException e)
    {
        Log.e(TAG, "Unable to provide a OneCameraManager. ", e);
    }
    mDisplayRotation = CameraUtil.getDisplayRotation();
    mCameraFacing = getFacingFromCameraId(
            mSettingsManager.getInteger(mAppController.getModuleScope(), Keys.KEY_CAMERA_ID));
    mShowErrorAndFinish = !updateCameraCharacteristics();
    if (mShowErrorAndFinish)
    {
        return;
    }
    mUI = new CaptureModuleUI(activity, mAppController.getModuleLayoutRoot(), mUIListener);
    mAppController.setPreviewStatusListener(mPreviewStatusListener);
    synchronized (mSurfaceTextureLock)
    {
        mPreviewSurfaceTexture = mAppController.getCameraAppUI().getSurfaceTexture();
    }
    mSoundPlayer = new SoundPlayer(mContext);

    FocusSound focusSound = new FocusSound(mSoundPlayer, R.raw.material_camera_focus);
    mFocusController = new FocusController(mUI.getFocusRing(), focusSound, mMainThread);

    mHeadingSensor = new HeadingSensor(AndroidServices.instance().provideSensorManager());

    View cancelButton = activity.findViewById(R.id.shutter_cancel_button);
    cancelButton.setOnClickListener(new View.OnClickListener()
    {
        @Override
        public void onClick(View view)
        {
            cancelCountDown();
        }
    });

    mMediaActionSound.load(MediaActionSound.SHUTTER_CLICK);
    guard.stop();
}
 
Example #19
Source File: ResourceCaptureToolsImpl.java    From Camera2 with Apache License 2.0 4 votes vote down vote up
@Override
public MediaActionSound getMediaActionSound()
{
    return mMediaActionSound;
}
 
Example #20
Source File: RecordButton.java    From sandriosCamera with MIT License 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void takePhoto(MediaActionSound sound) {
    sound.play(MediaActionSound.SHUTTER_CLICK);
    takePhoto();
}
 
Example #21
Source File: RecordButton.java    From sandriosCamera with MIT License 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void startRecording(MediaActionSound sound) {
    sound.play(MediaActionSound.START_VIDEO_RECORDING);
    startRecording();
}
 
Example #22
Source File: RecordButton.java    From sandriosCamera with MIT License 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void stopRecording(MediaActionSound sound) {
    sound.play(MediaActionSound.STOP_VIDEO_RECORDING);
    stopRecording();
}
 
Example #23
Source File: CaptureModule.java    From Camera2 with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a new capture module.
 */
public CaptureModule(AppController appController, boolean stickyHdr)
{
    super(appController);
    Profile guard = mProfiler.create("new CaptureModule").start();
    mPaused = true;
    mMainThread = MainThread.create();
    mAppController = appController;
    mContext = mAppController.getAndroidContext();
    mSettingsManager = mAppController.getSettingsManager();
    mStickyGcamCamera = stickyHdr;
    mLocationManager = mAppController.getLocationManager();
    mPreviewTransformCalculator = new PreviewTransformCalculator(
            mAppController.getOrientationManager());

    mBurstController = BurstFacadeFactory.create(mContext,
            new OrientationLockController()
            {
                @Override
                public void unlockOrientation()
                {
                    mAppController.getOrientationManager().unlockOrientation();
                }

                @Override
                public void lockOrientation()
                {
                    mAppController.getOrientationManager().lockOrientation();
                }
            },
            new BurstReadyStateChangeListener()
            {
                @Override
                public void onBurstReadyStateChanged(boolean ready)
                {
                    // TODO: This needs to take into account the state of
                    // the whole system, not just burst.
                    onReadyStateChanged(false);
                }
            });
    mMediaActionSound = new MediaActionSound();
    guard.stop();
}
 
Example #24
Source File: GlobalScreenShot.java    From ScreenCapture with Apache License 2.0 4 votes vote down vote up
/**
 * @param context everything needs a context :(
 */
public GlobalScreenshot(Context context) {
  Resources r = context.getResources();
  mContext = context;
  LayoutInflater layoutInflater = (LayoutInflater)
      context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

  // Inflate the screenshot layout
  mScreenshotLayout = layoutInflater.inflate(R.layout.global_screenshot, null);
  mBackgroundView = (ImageView) mScreenshotLayout.findViewById(R.id.global_screenshot_background);
  mScreenshotView = (ImageView) mScreenshotLayout.findViewById(R.id.global_screenshot);
  mScreenshotFlash = (ImageView) mScreenshotLayout.findViewById(R.id.global_screenshot_flash);
  mScreenshotLayout.setFocusable(true);
  mScreenshotLayout.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
      // Intercept and ignore all touch events
      return true;
    }
  });

  // Setup the window that we are going to use
  mWindowLayoutParams = new WindowManager.LayoutParams(
      ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0, 0,
      WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
      WindowManager.LayoutParams.FLAG_FULLSCREEN
          | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
          | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
          | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED,
      PixelFormat.TRANSLUCENT);
  mWindowLayoutParams.setTitle("ScreenshotAnimation");
  mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

  mDisplay = mWindowManager.getDefaultDisplay();
  mDisplayMetrics = new DisplayMetrics();
  mDisplay.getRealMetrics(mDisplayMetrics);

  // Scale has to account for both sides of the bg
  mBgPadding = (float) r.getDimensionPixelSize(R.dimen.global_screenshot_bg_padding);
  mBgPaddingScale = mBgPadding / mDisplayMetrics.widthPixels;

  // Setup the Camera shutter sound
  mCameraSound = new MediaActionSound();
  mCameraSound.load(MediaActionSound.SHUTTER_CLICK);
}
 
Example #25
Source File: OneCameraZslImpl.java    From Camera2 with Apache License 2.0 4 votes vote down vote up
/**
 * Instantiates a new camera based on Camera 2 API.
 *
 * @param device          The underlying Camera 2 device.
 * @param characteristics The device's characteristics.
 * @param pictureSize     the size of the final image to be taken.
 */
OneCameraZslImpl(CameraDevice device, CameraCharacteristics characteristics, Size pictureSize)
{
    Log.v(TAG, "Creating new OneCameraZslImpl");

    mDevice = device;
    mCharacteristics = characteristics;
    mLensRange = LensRangeCalculator
            .getDiopterToRatioCalculator(characteristics);
    mDirection = new CameraDirectionProvider(mCharacteristics);
    mFullSizeAspectRatio = calculateFullSizeAspectRatio(characteristics);

    mCameraThread = new HandlerThread("OneCamera2");
    // If this thread stalls, it will delay viewfinder frames.
    mCameraThread.setPriority(Thread.MAX_PRIORITY);
    mCameraThread.start();
    mCameraHandler = new Handler(mCameraThread.getLooper());

    mCameraListenerThread = new HandlerThread("OneCamera2-Listener");
    mCameraListenerThread.start();
    mCameraListenerHandler = new Handler(mCameraListenerThread.getLooper());

    // TODO: Encoding on multiple cores results in preview jank due to
    // excessive GC.
    int numEncodingCores = CameraUtil.getNumCpuCores();
    mImageSaverThreadPool = new ThreadPoolExecutor(numEncodingCores, numEncodingCores, 10,
            TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());

    mCaptureManager =
            new ImageCaptureManager(MAX_CAPTURE_IMAGES, mCameraListenerHandler,
                    mImageSaverThreadPool);
    mCaptureManager.setCaptureReadyListener(new ImageCaptureManager.CaptureReadyListener()
    {
        @Override
        public void onReadyStateChange(boolean capturePossible)
        {
            mReadyStateManager.setInput(ReadyStateRequirement.CAPTURE_MANAGER_READY,
                    capturePossible);
        }
    });

    // Listen for changes to auto focus state and dispatch to
    // mFocusStateListener.
    mCaptureManager.addMetadataChangeListener(CaptureResult.CONTROL_AF_STATE,
            new ImageCaptureManager.MetadataChangeListener()
            {
                @Override
                public void onImageMetadataChange(Key<?> key, Object oldValue, Object newValue,
                                                  CaptureResult result)
                {
                    FocusStateListener listener = mFocusStateListener;
                    if (listener != null)
                    {
                        listener.onFocusStatusUpdate(
                                AutoFocusHelper.stateFromCamera2State(
                                        result.get(CaptureResult.CONTROL_AF_STATE)),
                                result.getFrameNumber());
                    }
                }
            });

    // Allocate the image reader to store all images received from the
    // camera.
    if (pictureSize == null)
    {
        // TODO The default should be selected by the caller, and
        // pictureSize should never be null.
        pictureSize = getDefaultPictureSize();
    }
    mCaptureImageReader = ImageReader.newInstance(pictureSize.getWidth(),
            pictureSize.getHeight(),
            sCaptureImageFormat, MAX_CAPTURE_IMAGES);

    mCaptureImageReader.setOnImageAvailableListener(mCaptureManager, mCameraHandler);
    mMediaActionSound.load(MediaActionSound.SHUTTER_CLICK);
}
 
Example #26
Source File: ResourceCaptureTools.java    From Camera2 with Apache License 2.0 2 votes vote down vote up
/**
 * Obtains the media action sound.
 *
 * @return A {@link android.media.MediaActionSound} object.
 */
MediaActionSound getMediaActionSound();