diff options
author | Angus Kong <shkong@google.com> | 2011-10-31 20:00:05 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-10-31 20:00:05 +0000 |
commit | be6fec51025dbaadf3f23467e0233d4fba50ad73 (patch) | |
tree | 5c3b3bc076c84c2a61f74410c853bc6e67d5a2d2 /src/com/android/camera | |
parent | 2f2eea563073f0a69f53c9ce858889d69cc790d6 (diff) | |
parent | 174b8b7fc4d55e8c63eb3ed0b71f1519a13e345d (diff) | |
download | LegacyCamera-be6fec51025dbaadf3f23467e0233d4fba50ad73.zip LegacyCamera-be6fec51025dbaadf3f23467e0233d4fba50ad73.tar.gz LegacyCamera-be6fec51025dbaadf3f23467e0233d4fba50ad73.tar.bz2 |
am 174b8b7f: Add forced sound for panorama mode.
* commit '174b8b7fc4d55e8c63eb3ed0b71f1519a13e345d':
Add forced sound for panorama mode.
Diffstat (limited to 'src/com/android/camera')
-rwxr-xr-x | src/com/android/camera/panorama/PanoramaActivity.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/com/android/camera/panorama/PanoramaActivity.java b/src/com/android/camera/panorama/PanoramaActivity.java index d95ac03..81859ec 100755 --- a/src/com/android/camera/panorama/PanoramaActivity.java +++ b/src/com/android/camera/panorama/PanoramaActivity.java @@ -26,6 +26,7 @@ import com.android.camera.ModePicker; import com.android.camera.OnClickAttr; import com.android.camera.R; import com.android.camera.ShutterButton; +import com.android.camera.SoundPlayer; import com.android.camera.Storage; import com.android.camera.Thumbnail; import com.android.camera.Util; @@ -37,6 +38,7 @@ import android.app.ProgressDialog; import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; +import android.content.res.AssetFileDescriptor; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -54,6 +56,8 @@ import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Message; +import android.os.ParcelFileDescriptor; +import android.os.SystemProperties; import android.util.Log; import android.view.Gravity; import android.view.Menu; @@ -65,6 +69,7 @@ import android.widget.ImageView; import android.widget.TextView; import java.io.ByteArrayOutputStream; +import java.io.FileNotFoundException; import java.io.File; import java.util.List; @@ -99,6 +104,8 @@ public class PanoramaActivity extends ActivityBase implements // Ratio of nanosecond to second private static final float NS2S = 1.0f / 1000000000.0f; + private static final String VIDEO_RECORD_SOUND = "/system/media/audio/ui/VideoRecord.ogg"; + private boolean mPausing; private View mPanoLayout; @@ -161,6 +168,8 @@ public class PanoramaActivity extends ActivityBase implements private float[] mTransformMatrix; private float mHorizontalViewAngle; + private SoundPlayer mRecordSound; + // Prefer FOCUS_MODE_INFINITY to FOCUS_MODE_CONTINUOUS_VIDEO because of // getting a better image quality by the former. private String mTargetFocusMode = Parameters.FOCUS_MODE_INFINITY; @@ -706,9 +715,11 @@ public class PanoramaActivity extends ActivityBase implements // right now. switch (mCaptureState) { case CAPTURE_STATE_VIEWFINDER: + if (mRecordSound != null) mRecordSound.play(); startCapture(); break; case CAPTURE_STATE_MOSAIC: + if (mRecordSound != null) mRecordSound.play(); stopCapture(false); } } @@ -900,6 +911,34 @@ public class PanoramaActivity extends ActivityBase implements mMosaicFrameProcessor.initialize(); } + private void initSoundRecorder() { + // Construct sound player; use enforced sound output if necessary + File recordSoundFile = new File(VIDEO_RECORD_SOUND); + try { + ParcelFileDescriptor recordSoundParcel = + ParcelFileDescriptor.open(recordSoundFile, + ParcelFileDescriptor.MODE_READ_ONLY); + AssetFileDescriptor recordSoundAsset = + new AssetFileDescriptor(recordSoundParcel, 0, + AssetFileDescriptor.UNKNOWN_LENGTH); + if (SystemProperties.get("ro.camera.sound.forced", "0").equals("0")) { + mRecordSound = new SoundPlayer(recordSoundAsset, false); + } else { + mRecordSound = new SoundPlayer(recordSoundAsset, true); + } + } catch (java.io.FileNotFoundException e) { + Log.e(TAG, "System video record sound not found"); + mRecordSound = null; + } + } + + private void releaseSoundRecorder() { + if (mRecordSound != null) { + mRecordSound.release(); + mRecordSound = null; + } + } + @Override protected void onPause() { super.onPause(); @@ -918,6 +957,7 @@ public class PanoramaActivity extends ActivityBase implements } releaseCamera(); + releaseSoundRecorder(); mMosaicView.onPause(); clearMosaicFrameProcessorIfNeeded(); mOrientationEventListener.disable(); @@ -933,6 +973,8 @@ public class PanoramaActivity extends ActivityBase implements mCaptureState = CAPTURE_STATE_VIEWFINDER; setupCamera(); + initSoundRecorder(); + // Camera must be initialized before MosaicFrameProcessor is initialized. The preview size // has to be decided by camera device. initMosaicFrameProcessorIfNeeded(); |