focusModes = parameters.getSupportedFocusModes();
178 | if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO))
179 | parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
180 |
181 | int[] closetFramerate = CameraUtils.closetFramerate(parameters, 30);
182 | parameters.setPreviewFpsRange(closetFramerate[0], closetFramerate[1]);
183 |
184 | CameraUtils.choosePreviewSize(parameters, desiredWidth, desiredHeight);
185 | mCamera.setParameters(parameters);
186 | }
187 | }
188 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aserbao/cameravideorecord/cameraDemo01/CameraTakePictureActivity.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.cameravideorecord.cameraDemo01;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.BitmapFactory;
5 | import android.hardware.Camera;
6 | import android.media.MediaRecorder;
7 | import android.os.Bundle;
8 | import android.os.Environment;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.util.Log;
11 | import android.view.SurfaceHolder;
12 | import android.view.SurfaceView;
13 | import android.view.View;
14 | import android.widget.Button;
15 | import android.widget.ImageView;
16 | import android.widget.Toast;
17 |
18 | import com.aserbao.cameravideorecord.R;
19 |
20 | import java.io.File;
21 | import java.io.IOException;
22 |
23 | import butterknife.BindView;
24 | import butterknife.ButterKnife;
25 | import butterknife.OnClick;
26 |
27 | public class CameraTakePictureActivity extends AppCompatActivity implements SurfaceHolder.Callback, Camera.PictureCallback {
28 | private static final String TAG = "CameraTakePictureActivi";
29 |
30 |
31 | @BindView(R.id.picture_sv)
32 | SurfaceView mPictureSv;
33 | @BindView(R.id.image_view)
34 | ImageView mImageView;
35 | @BindView(R.id.take_picture)
36 | Button mTakePicture;
37 | @BindView(R.id.btn_recording)
38 | Button mBtnRecording;
39 | @BindView(R.id.btn_start_preview)
40 | Button mBtnStartPreview;
41 | private Camera mCamera;
42 | private SurfaceHolder mHolder;
43 | private Bitmap mBitmap;
44 | private MediaRecorder mMediaRecorder;
45 | private boolean isRecording = false;
46 |
47 | @Override
48 | protected void onCreate(Bundle savedInstanceState) {
49 | super.onCreate(savedInstanceState);
50 | setContentView(R.layout.activity_camera_take_picture);
51 | ButterKnife.bind(this);
52 | mHolder = mPictureSv.getHolder();
53 | // mHolder.setFormat(PixelFormat.TRANSPARENT);
54 | // mHolder.addCallback(this);
55 | // mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
56 | }
57 |
58 | @Override
59 | protected void onResume() {
60 | super.onResume();
61 | }
62 |
63 | private void openCamera() {
64 | mCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT);
65 | Camera.Parameters parameters = mCamera.getParameters();
66 | mCamera.setParameters(parameters);
67 | mCamera.setDisplayOrientation(90);
68 | try {
69 | mCamera.setPreviewDisplay(mHolder);
70 | } catch (IOException e) {
71 | e.printStackTrace();
72 | }
73 | mCamera.startPreview();
74 | }
75 |
76 | @Override
77 | public void surfaceCreated(SurfaceHolder holder) {
78 |
79 | }
80 |
81 | @Override
82 | public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
83 |
84 | }
85 |
86 | @Override
87 | public void surfaceDestroyed(SurfaceHolder holder) {
88 |
89 | }
90 |
91 | @Override
92 | public void onPictureTaken(byte[] data, Camera camera) {
93 | if (data != null) {
94 | Log.e(TAG, "onPictureTaken: " + data.toString());
95 | }
96 | }
97 |
98 | @Override
99 | public void onPointerCaptureChanged(boolean hasCapture) {
100 | Log.e(TAG, "onPointerCaptureChanged: " + hasCapture);
101 | }
102 |
103 | @OnClick({R.id.take_picture, R.id.btn_recording, R.id.btn_start_preview})
104 | public void onViewClicked(View view) {
105 | switch (view.getId()) {
106 | case R.id.btn_start_preview:
107 | openCamera();
108 | mImageView.setVisibility(View.GONE);
109 | break;
110 | case R.id.take_picture:
111 | mCamera.takePicture(new Camera.ShutterCallback() {
112 | @Override
113 | public void onShutter() {
114 | Log.e(TAG, "onShutter: " + "按下快门");
115 | }
116 | }, new Camera.PictureCallback() {
117 | @Override
118 | public void onPictureTaken(byte[] data, Camera camera) {
119 | if (data != null) {
120 | showImageView(data);
121 | Log.e(TAG, "onPictureTaken: " + data.toString());
122 | }
123 | }
124 | }, new Camera.PictureCallback() {
125 | @Override
126 | public void onPictureTaken(byte[] data, Camera camera) {
127 | if (data != null) {
128 | showImageView(data);
129 | Log.e(TAG, "onPictureTaken2: " + data.toString());
130 | }
131 | }
132 | });
133 | break;
134 | case R.id.btn_recording:
135 | if(!isRecording){
136 | mBtnRecording.setText("停止录制");
137 | startRecording();
138 | }else{
139 | mBtnRecording.setText("开始录制");
140 | stopRecording();
141 | }
142 | break;
143 | }
144 | }
145 |
146 | private void startRecording() {
147 | try {
148 | mCamera.unlock();
149 | mMediaRecorder = new MediaRecorder();
150 | /* String filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath() + "/ych/123.mp4";
151 | new File(filePath);*/
152 | File file = new File(Environment.getExternalStorageDirectory().getCanonicalFile() + "/1234.mp4");
153 | mMediaRecorder.reset();
154 | mMediaRecorder.setCamera(mCamera);
155 | mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
156 | mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
157 | mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
158 | mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
159 | // mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
160 | // mMediaRecorder.setVideoSize(320, 240);//每个手机的屏幕视频都不一样,需要调整
161 | // mMediaRecorder.setVideoFrameRate(4);
162 | mMediaRecorder.setVideoEncoder(MediaRecorder
163 | .VideoEncoder.H264);
164 | mMediaRecorder.setVideoSize(1280, 720);
165 | // 每秒 4帧
166 | mMediaRecorder.setOrientationHint(90);
167 | mMediaRecorder.setVideoFrameRate(20);
168 | mMediaRecorder.setPreviewDisplay(mHolder.getSurface()); // ①
169 | mMediaRecorder.setOutputFile(file.getAbsolutePath());
170 | mMediaRecorder.prepare();
171 | mMediaRecorder.start();
172 | isRecording = true;
173 | } catch (Exception e) {
174 | e.printStackTrace();
175 | }
176 | Toast.makeText(this, "成功", Toast.LENGTH_SHORT).show();
177 | }
178 |
179 | private void stopRecording() {
180 | if (mMediaRecorder != null) {
181 | isRecording = false;
182 | mMediaRecorder.stop();
183 | mMediaRecorder.release();
184 | mMediaRecorder = null;
185 | }
186 | }
187 |
188 | private void showImageView(byte[] data) {
189 | mBitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
190 | mImageView.setImageBitmap(mBitmap);
191 | mImageView.setVisibility(View.VISIBLE);
192 | }
193 |
194 | @Override
195 | protected void onPause() {
196 | super.onPause();
197 | mCamera.stopPreview();
198 | }
199 |
200 | @Override
201 | protected void onDestroy() {
202 | super.onDestroy();
203 | mCamera.release();
204 | }
205 | }
206 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aserbao/cameravideorecord/cameraDemo01/RecordingActivity.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.cameravideorecord.cameraDemo01;
2 |
3 | import android.media.MediaPlayer;
4 | import android.media.MediaRecorder;
5 | import android.os.Bundle;
6 | import android.os.Environment;
7 | import android.os.Handler;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.util.Log;
10 | import android.view.View;
11 | import android.widget.Button;
12 | import android.widget.ImageView;
13 | import android.widget.TextView;
14 |
15 | import com.aserbao.cameravideorecord.R;
16 | import com.aserbao.cameravideorecord.utils.MediaUtils;
17 |
18 | import java.io.File;
19 | import java.io.IOException;
20 |
21 | import butterknife.BindView;
22 | import butterknife.ButterKnife;
23 | import butterknife.OnClick;
24 |
25 | /**
26 | * 这个一个带录音功能的Activity
27 | */
28 | public class RecordingActivity extends AppCompatActivity {
29 | @BindView(R.id.start_recording)
30 | Button mStartRecording;
31 | @BindView(R.id.play_recording)
32 | Button mPlayRecording;
33 | @BindView(R.id.textView)
34 | TextView mTextView;
35 | @BindView(R.id.image_view)
36 | ImageView mImageView;
37 | private MediaRecorder mRecorder;
38 | private boolean isRecording = false;
39 | private String mAbsolutePath;
40 | private boolean isPlaying = false;
41 | private MediaPlayer mMediaPlayer;
42 |
43 | @Override
44 | protected void onCreate(Bundle savedInstanceState) {
45 | super.onCreate(savedInstanceState);
46 | setContentView(R.layout.activity_recording);
47 | ButterKnife.bind(this);
48 | mPlayRecording.setClickable(false);
49 | }
50 |
51 | @OnClick({R.id.start_recording, R.id.play_recording})
52 | public void onViewClicked(View view){
53 | switch (view.getId()) {
54 | case R.id.start_recording:
55 | if (!isRecording) {
56 | mPlayRecording.setClickable(false);
57 | mStartRecording.setText("停止录音");
58 | isRecording = true;
59 | mStartRecording();
60 | } else {
61 | mPlayRecording.setClickable(true);
62 | mStartRecording.setText("开始录音");
63 | isRecording = false;
64 | mStopRecording();
65 | }
66 | break;
67 | case R.id.play_recording:
68 | if (!isPlaying) {
69 | try {
70 | mStartRecording.setClickable(false);
71 | isPlaying = true;
72 | mPlayRecording.setText("暂停播放");
73 | mMediaPlayer = new MediaPlayer();
74 | mMediaPlayer.setDataSource(mAbsolutePath);
75 | mMediaPlayer.prepare();
76 | mMediaPlayer.start();
77 | } catch (IOException e) {
78 | e.printStackTrace();
79 | }
80 | } else {
81 | mStartRecording.setClickable(true);
82 | if (mMediaPlayer != null) {
83 | isPlaying = false;
84 | mPlayRecording.setText("开始播放");
85 | mMediaPlayer.pause();
86 | }
87 | }
88 | break;
89 | }
90 | }
91 |
92 | private void mStopRecording() {
93 | mRecorder.stop();
94 | mRecorder.reset();
95 | mRecorder.release();
96 | }
97 |
98 | private void mStartRecording() {
99 | try {
100 | String s = Environment.getExternalStorageDirectory().getCanonicalFile().getAbsolutePath() + "/aserbao";
101 | boolean b = new File(s).mkdir();
102 | mAbsolutePath = new File(s + "/" + String.valueOf(System.currentTimeMillis()) + ".3gp").getAbsolutePath();
103 | mRecorder = MediaUtils.startRecording(mAbsolutePath);
104 | updateAudioSize();
105 | mTextView.setText("录音保存的路径名为:" + mAbsolutePath.toString());
106 | } catch (IOException e) {
107 | e.printStackTrace();
108 | }
109 | }
110 |
111 | private final Handler mHandler = new Handler();
112 | private Runnable mUpdateMicStatusTimer = new Runnable() {
113 | public void run() {
114 | updateAudioSize();
115 | }
116 | };
117 |
118 | private int BASE = 600;
119 | private int SPACE = 300;// 间隔取样时间
120 | private void updateAudioSize() {
121 | if (mRecorder != null && mImageView != null){
122 | int audio = mRecorder.getMaxAmplitude()/BASE;
123 | int db = 0;
124 | if (audio > 1)
125 | db = (int) (20 * Math.log10(audio));
126 | Log.e("audio_size", "updateAudioSize: " + String.valueOf(db/4) + "==================getMaxAmplitude: " + String.valueOf(mRecorder.getMaxAmplitude()));
127 | switch (db / 4) {
128 | case 0:
129 | mImageView.setImageResource(R.drawable.message_vioce01);
130 | break;
131 | case 1:
132 | mImageView.setImageResource(R.drawable.message_vioce01);
133 | break;
134 | case 2:
135 | mImageView.setImageResource(R.drawable.message_vioce02);
136 | break;
137 | case 3:
138 | mImageView.setImageResource(R.drawable.message_vioce03);
139 | break;
140 | case 4:
141 | mImageView.setImageResource(R.drawable.message_vioce04);
142 | break;
143 | case 5:
144 | mImageView.setImageResource(R.drawable.message_vioce05);
145 | break;
146 | case 6:
147 | mImageView.setImageResource(R.drawable.message_vioce06);
148 | break;
149 | case 7:
150 | mImageView.setImageResource(R.drawable.message_vioce07);
151 | break;
152 | case 8:
153 | mImageView.setImageResource(R.drawable.message_vioce08);
154 | break;
155 | default:
156 | mImageView.setImageResource(R.drawable.message_vioce08);
157 | break;
158 | }
159 | mHandler.postDelayed(mUpdateMicStatusTimer, SPACE);
160 | }
161 | }
162 |
163 | }
164 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aserbao/cameravideorecord/utils/CameraUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Google Inc. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.aserbao.cameravideorecord.utils;
18 |
19 | import android.app.Activity;
20 | import android.hardware.Camera;
21 | import android.util.Log;
22 | import android.view.Surface;
23 |
24 | import java.util.List;
25 |
26 | /**
27 | * Camera-related utility functions.
28 | */
29 | public class CameraUtils {
30 | private static final String TAG = "CameraUtils";
31 |
32 | /**
33 | * Attempts to find a preview size that matches the provided width and height (which
34 | * specify the dimensions of the encoded video). If it fails to find a match it just
35 | * uses the default preview size for video.
36 | *
37 | * TODO: should do a best-fit match, e.g.
38 | * https://github.com/commonsguy/cwac-camera/blob/master/camera/src/com/commonsware/cwac/camera/CameraUtils.java
39 | */
40 | public static void choosePreviewSize(Camera.Parameters parms, int width, int height) {
41 | // We should make sure that the requested MPEG size is less than the preferred
42 | // size, and has the same aspect ratio.
43 | Camera.Size ppsfv = parms.getPreferredPreviewSizeForVideo();
44 | if (ppsfv != null) {
45 | Log.d(TAG, "Camera preferred preview size for video is " +
46 | ppsfv.width + "x" + ppsfv.height);
47 | }
48 |
49 | //for (Camera.Size size : parms.getSupportedPreviewSizes()) {
50 | // Log.d(TAG, "supported: " + size.width + "x" + size.height);
51 | //}
52 |
53 | for (Camera.Size size : parms.getSupportedPreviewSizes()) {
54 | if (size.width == width && size.height == height) {
55 | parms.setPreviewSize(width, height);
56 | return;
57 | }
58 | }
59 |
60 | Log.w(TAG, "Unable to set preview size to " + width + "x" + height);
61 | if (ppsfv != null) {
62 | parms.setPreviewSize(ppsfv.width, ppsfv.height);
63 | }
64 | // else use whatever the default size is
65 | }
66 |
67 | /**
68 | * Attempts to find a fixed preview frame rate that matches the desired frame rate.
69 | *
70 | * It doesn't seem like there's a great deal of flexibility here.
71 | *
72 | * TODO: follow the recipe from http://stackoverflow.com/questions/22639336/#22645327
73 | *
74 | * @return The expected frame rate, in thousands of frames per second.
75 | */
76 | public static int chooseFixedPreviewFps(Camera.Parameters parms, int desiredThousandFps) {
77 | List supported = parms.getSupportedPreviewFpsRange();
78 |
79 | for (int[] entry : supported) {
80 | //Log.d(TAG, "entry: " + entry[0] + " - " + entry[1]);
81 | if ((entry[0] == entry[1]) && (entry[0] == desiredThousandFps)) {
82 | parms.setPreviewFpsRange(entry[0], entry[1]);
83 | return entry[0];
84 | }
85 | }
86 |
87 | int[] tmp = new int[2];
88 | parms.getPreviewFpsRange(tmp);
89 | int guess;
90 | if (tmp[0] == tmp[1]) {
91 | guess = tmp[0];
92 | } else {
93 | guess = tmp[1] / 2; // shrug
94 | }
95 |
96 | Log.d(TAG, "Couldn't find match for " + desiredThousandFps + ", using " + guess);
97 | return guess;
98 | }
99 |
100 | /**
101 | * reference http://www.jianshu.com/p/1513134733d0
102 | */
103 | public static void setCameraDisplayOrientation(Activity activity,
104 | int cameraId, Camera camera) {
105 | Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
106 | Camera.getCameraInfo(cameraId, info);
107 | int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
108 | int degrees = 0;
109 | switch (rotation) {
110 | case Surface.ROTATION_0:
111 | degrees = 0;
112 | break;
113 | case Surface.ROTATION_90:
114 | degrees = 90;
115 | break;
116 | case Surface.ROTATION_180:
117 | degrees = 180;
118 | break;
119 | case Surface.ROTATION_270:
120 | degrees = 270;
121 | break;
122 | }
123 |
124 | int result;
125 | if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
126 | result = (info.orientation + degrees) % 360;
127 | result = (360 - result) % 360; // compensate the mirror
128 | } else { // back-facing
129 | result = (info.orientation - degrees + 360) % 360;
130 | }
131 | camera.setDisplayOrientation(result);
132 | }
133 |
134 | //TODO: follow the recipe from http://stackoverflow.com/questions/22639336/#22645327
135 | public static int[] closetFramerate(Camera.Parameters parameters, float frameRate) {
136 | int framerate = (int) (frameRate * 1000);
137 | List rates = parameters.getSupportedPreviewFpsRange();
138 | int[] bestFramerate = rates.get(0);
139 | for (int i = 0; i < rates.size(); i++) {
140 | int[] rate = rates.get(i);
141 | Log.e(TAG, "supported preview pfs min " + rate[0] + " max " + rate[1]);
142 | int curDelta = Math.abs(rate[1] - framerate);
143 | int bestDelta = Math.abs(bestFramerate[1] - framerate);
144 | if (curDelta < bestDelta) {
145 | bestFramerate = rate;
146 | } else if (curDelta == bestDelta) {
147 | bestFramerate = bestFramerate[0] < rate[0] ? rate : bestFramerate;
148 | }
149 | }
150 | return bestFramerate;
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aserbao/cameravideorecord/utils/MediaUtils.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.cameravideorecord.utils;
2 |
3 | import android.media.MediaRecorder;
4 | import android.os.Environment;
5 | import android.text.TextUtils;
6 |
7 | import java.io.File;
8 | import java.io.IOException;
9 |
10 | /**
11 | * description:
12 | * Created by aserbao on 2017/11/29.
13 | */
14 |
15 |
16 | public class MediaUtils {
17 |
18 |
19 | public static MediaRecorder startRecording(String mAbsolutePath){
20 | if (TextUtils.isEmpty(mAbsolutePath)){
21 | return null;
22 | }
23 | try {
24 | MediaRecorder mRecorder = new MediaRecorder();
25 | mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
26 | mRecorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
27 | mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
28 | mRecorder.setOutputFile(mAbsolutePath);
29 | mRecorder.prepare();
30 | mRecorder.start();
31 | return mRecorder;
32 | } catch (IOException e) {
33 | e.printStackTrace();
34 | return null;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/message_vioce01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/drawable/message_vioce01.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/message_vioce02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/drawable/message_vioce02.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/message_vioce03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/drawable/message_vioce03.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/message_vioce04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/drawable/message_vioce04.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/message_vioce05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/drawable/message_vioce05.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/message_vioce06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/drawable/message_vioce06.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/message_vioce07.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/drawable/message_vioce07.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/message_vioce08.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/drawable/message_vioce08.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_camera_take_picture.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
23 |
31 |
36 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
19 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_recording.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
17 |
25 |
30 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CameraVideoRecord
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/aserbao/cameravideorecord/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.cameravideorecord;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.3'
9 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | ## Project-wide Gradle settings.
2 | #
3 | # For more details on how to configure your build environment visit
4 | # http://www.gradle.org/docs/current/userguide/build_environment.html
5 | #
6 | # Specifies the JVM arguments used for the daemon process.
7 | # The setting is particularly useful for tweaking memory settings.
8 | # Default value: -Xmx1024m -XX:MaxPermSize=256m
9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
10 | #
11 | # When configured, Gradle will run in incubating parallel mode.
12 | # This option should only be used with decoupled projects. More details, visit
13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
14 | # org.gradle.parallel=true
15 | #Fri Nov 24 17:33:37 CST 2017
16 | systemProp.http.proxyHost=127.0.0.1
17 | org.gradle.jvmargs=-Xmx1536m
18 | systemProp.http.proxyPort=8087
19 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/CameraVideoRecord/d7a1866f3e9407231d38018c620b420a19be0bcd/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Nov 24 17:33:33 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------