summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/CaptureModule.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/CaptureModule.java')
-rw-r--r--src/com/android/camera/CaptureModule.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index b33cb361f..1a7811000 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -52,6 +52,7 @@ import android.media.CamcorderProfile;
import android.media.CameraProfile;
import android.media.Image;
import android.media.ImageReader;
+import android.media.MediaActionSound;
import android.media.MediaMetadataRetriever;
import android.media.MediaRecorder;
import android.net.Uri;
@@ -278,6 +279,8 @@ public class CaptureModule implements CameraModule, PhotoController,
private static final int SELFIE_FLASH_DURATION = 680;
+ private MediaActionSound mSound;
+
private class SelfieThread extends Thread {
public void run() {
try {
@@ -1061,6 +1064,7 @@ public class CaptureModule implements CameraModule, PhotoController,
warningToast("Camera is not ready yet to take a picture.");
return;
}
+ checkAndPlayShutterSound(id);
final boolean csEnabled = isClearSightOn();
CaptureRequest.Builder captureBuilder;
@@ -1187,6 +1191,7 @@ public class CaptureModule implements CameraModule, PhotoController,
warningToast("Camera is not ready yet to take a video snapshot.");
return;
}
+ checkAndPlayShutterSound(id);
CaptureRequest.Builder captureBuilder =
mCameraDevice[id].createCaptureRequest(CameraDevice.TEMPLATE_VIDEO_SNAPSHOT);
@@ -1623,6 +1628,10 @@ public class CaptureModule implements CameraModule, PhotoController,
if (mIsRecordingVideo) {
stopRecordingVideo(getMainCameraId());
}
+ if (mSound != null) {
+ mSound.release();
+ mSound = null;
+ }
if (selfieThread != null) {
selfieThread.interrupt();
}
@@ -1754,6 +1763,11 @@ public class CaptureModule implements CameraModule, PhotoController,
mUI.showSurfaceView();
mUI.setSwitcherIndex();
mCameraIdList = new ArrayList<>();
+
+ if (mSound == null) {
+ mSound = new MediaActionSound();
+ }
+
if(mPostProcessor != null) {
String scene = mSettingsManager.getValue(SettingsManager.KEY_SCENE_MODE);
if (scene != null) {
@@ -3011,6 +3025,15 @@ public class CaptureModule implements CameraModule, PhotoController,
}
}
+ private void checkAndPlayShutterSound(int id) {
+ if (id == getMainCameraId()) {
+ String value = mSettingsManager.getValue(SettingsManager.KEY_SHUTTER_SOUND);
+ if (value != null && value.equals("on")) {
+ mSound.play(MediaActionSound.SHUTTER_CLICK);
+ }
+ }
+ }
+
private Surface getPreviewSurfaceForSession(int id) {
if (isBackCamera()) {
if (getCameraMode() == DUAL_MODE && id == MONO_ID) {