mirror of
				https://github.com/SimpleMobileTools/Simple-Camera.git
				synced 2025-06-27 09:02:59 +02:00 
			
		
		
		
	close #21, apply the Shutter sound option to video recording too
This commit is contained in:
		| @@ -4,6 +4,7 @@ import android.content.Context; | |||||||
| import android.graphics.Point; | import android.graphics.Point; | ||||||
| import android.graphics.Rect; | import android.graphics.Rect; | ||||||
| import android.hardware.Camera; | import android.hardware.Camera; | ||||||
|  | import android.media.AudioManager; | ||||||
| import android.media.CamcorderProfile; | import android.media.CamcorderProfile; | ||||||
| import android.media.MediaActionSound; | import android.media.MediaActionSound; | ||||||
| import android.media.MediaRecorder; | import android.media.MediaRecorder; | ||||||
| @@ -701,7 +702,9 @@ public class Preview extends ViewGroup | |||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             mCamera.unlock(); |             mCamera.unlock(); | ||||||
|  |             toggleShutterSound(true); | ||||||
|             mRecorder.start(); |             mRecorder.start(); | ||||||
|  |             toggleShutterSound(false); | ||||||
|             mIsRecording = true; |             mIsRecording = true; | ||||||
|         } catch (Exception e) { |         } catch (Exception e) { | ||||||
|             Utils.showToast(mContext, R.string.video_setup_error); |             Utils.showToast(mContext, R.string.video_setup_error); | ||||||
| @@ -713,10 +716,12 @@ public class Preview extends ViewGroup | |||||||
|     private void stopRecording() { |     private void stopRecording() { | ||||||
|         if (mRecorder != null && mIsRecording) { |         if (mRecorder != null && mIsRecording) { | ||||||
|             try { |             try { | ||||||
|  |                 toggleShutterSound(true); | ||||||
|                 mRecorder.stop(); |                 mRecorder.stop(); | ||||||
|                 final String[] paths = {mCurVideoPath}; |                 final String[] paths = {mCurVideoPath}; | ||||||
|                 MediaScannerConnection.scanFile(mContext, paths, null, this); |                 MediaScannerConnection.scanFile(mContext, paths, null, this); | ||||||
|             } catch (RuntimeException e) { |             } catch (RuntimeException e) { | ||||||
|  |                 toggleShutterSound(false); | ||||||
|                 new File(mCurVideoPath).delete(); |                 new File(mCurVideoPath).delete(); | ||||||
|                 Utils.showToast(mContext, R.string.video_saving_error); |                 Utils.showToast(mContext, R.string.video_saving_error); | ||||||
|                 Log.e(TAG, "stopRecording " + e.getMessage()); |                 Log.e(TAG, "stopRecording " + e.getMessage()); | ||||||
| @@ -735,6 +740,12 @@ public class Preview extends ViewGroup | |||||||
|         } |         } | ||||||
| } | } | ||||||
|  |  | ||||||
|  |     private void toggleShutterSound(Boolean mute) { | ||||||
|  |         if (!Config.newInstance(mContext).getIsSoundEnabled()) { | ||||||
|  |             ((AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE)).setStreamMute(AudioManager.STREAM_SYSTEM, mute); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onClick(View v) { |     public void onClick(View v) { | ||||||
|         if (!mWasZooming) |         if (!mWasZooming) | ||||||
| @@ -747,6 +758,7 @@ public class Preview extends ViewGroup | |||||||
|     @Override |     @Override | ||||||
|     public void onScanCompleted(String path, Uri uri) { |     public void onScanCompleted(String path, Uri uri) { | ||||||
|         mCallback.videoSaved(uri); |         mCallback.videoSaved(uri); | ||||||
|  |         toggleShutterSound(false); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static class SizesComparator implements Comparator<Camera.Size>, Serializable { |     private static class SizesComparator implements Comparator<Camera.Size>, Serializable { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user