mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-02-02 08:16:44 +01:00
init video recorder only when the surface is ready
This commit is contained in:
parent
e04be7886f
commit
9e0a11c5d7
@ -188,20 +188,20 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
|
|||||||
toggleCameraBtn.setVisibility(View.VISIBLE);
|
toggleCameraBtn.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if (isPhoto) {
|
if (isPhoto) {
|
||||||
initPhoto();
|
initPhotoButtons();
|
||||||
} else {
|
} else {
|
||||||
initVideo();
|
initVideoButtons();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initPhoto() {
|
private void initPhotoButtons() {
|
||||||
final Resources res = getResources();
|
final Resources res = getResources();
|
||||||
togglePhotoVideoBtn.setImageDrawable(res.getDrawable(R.mipmap.videocam));
|
togglePhotoVideoBtn.setImageDrawable(res.getDrawable(R.mipmap.videocam));
|
||||||
shutterBtn.setImageDrawable(res.getDrawable(R.mipmap.camera));
|
shutterBtn.setImageDrawable(res.getDrawable(R.mipmap.camera));
|
||||||
preview.initPhotoMode();
|
preview.initPhotoMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initVideo() {
|
private void initVideoButtons() {
|
||||||
final Resources res = getResources();
|
final Resources res = getResources();
|
||||||
togglePhotoVideoBtn.setImageDrawable(res.getDrawable(R.mipmap.photo));
|
togglePhotoVideoBtn.setImageDrawable(res.getDrawable(R.mipmap.photo));
|
||||||
shutterBtn.setImageDrawable(res.getDrawable(R.mipmap.video_rec));
|
shutterBtn.setImageDrawable(res.getDrawable(R.mipmap.video_rec));
|
||||||
@ -258,8 +258,7 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isPhoto) {
|
if (!isPhoto) {
|
||||||
preview.initRecorder();
|
initVideoButtons();
|
||||||
initVideo();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,6 +236,10 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
|
|||||||
@Override
|
@Override
|
||||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||||
setupPreview();
|
setupPreview();
|
||||||
|
|
||||||
|
if (isVideoMode) {
|
||||||
|
initRecorder();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupPreview() {
|
private void setupPreview() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user