I'm new to Android and Java so forgive me if the answer is obvious, but I can't get my video recorder app to work. I can see the image just fine in the camera preview (that code works fine) but when I go to record, I only record sound. I've implemented the code fragments recommended by Google (below) but it's not working. I've tried everything I can think of. Any insight would be appreciated.
protected void onCreate(Bundle savedInstanceState) {
int x;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_camera);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.container, new PlaceholderFragment()).commit();
// Create an instance of Camera
x = Camera.getNumberOfCameras();
mCamera = getCameraInstance(x-1);
recorder = new MediaRecorder();
// Create our Preview view and set it as the content of our activity.
mPreview = new VideoCameraPreview(this, x-1, mCamera);
FrameLayout preview = (FrameLayout) findViewById(R.id.video_camera_preview);
preview.addView(mPreview);
try {
mCamera.setPreviewDisplay(VideoCameraPreview.mHolder);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Add a listener to the Capture button
final Button captureButton = (Button) findViewById(R.id.button_capture);
captureButton.setOnClickListener(
new View.OnClickListener() {
#Override
public void onClick(View v) {
if (isRecording) {
// stop recording and release camera
recorder.stop(); // stop the recording
// releaseMediaRecorder(); // release the MediaRecorder object
mCamera.lock(); // take camera access back from MediaRecorder
// inform the user that recording has stopped
captureButton.setText("Capture");
isRecording = false;
} else {
// initialize video camera
if (prepareVideoRecorder()) {
// Camera is available and unlocked, MediaRecorder is prepared,
// now you can start recording
recorder.start();
// inform the user that recording has started
captureButton.setText("Stop");
isRecording = true;
} else {
// prepare didn't work, release the camera
releaseMediaRecorder();
// inform user
}
}
}
}
);
}
private boolean prepareVideoRecorder (){
//Record a video in response to a user pressing the button
int x = Camera.getNumberOfCameras();
mCamera.unlock(); //Unlock the camera for use by the Media Recorder
recorder.setCamera(mCamera); // Get the camera ready for recording
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
recorder.setProfile(CamcorderProfile.get(x-1, CamcorderProfile.QUALITY_HIGH));
recorder.setOutputFile(getOutputMediaFile(MEDIA_TYPE_VIDEO).toString());
recorder.setPreviewDisplay(VideoCameraPreview.mHolder.getSurface());
try {
recorder.prepare();
} catch (IllegalStateException e) {
Log.d("Wink", "Illegal stateException preparing MediaRecorder: " + e.getMessage());
recorder.release();
return false;
} catch (IOException e) {
Log.d("Wink", "IOException preparing MediaRecorder: " + e.getMessage());
recorder.release();
return false;
}
return true;
}
I haven't gone over that in much depth but here's a link to another video recorder for Android that might help you.
Display timer while video recording android
Change setVideoSource and setAudioSource and try to set the output format for the video and set both encoders.
recorder.setCamera(mCamera); // Get the camera ready for recording
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
recorder.setProfile(CamcorderProfile.get(x-1, CamcorderProfile.QUALITY_HIGH));
recorder.setOutputFile(getOutputMediaFile(MEDIA_TYPE_VIDEO).toString());
recorder.setPreviewDisplay(VideoCameraPreview.mHolder.getSurface());
Related
I am trying to find a way to have a timer start the video recorder in android. I open it with an intent but it comes up with the red start recording button. Is there a way I can control the stop and start recording in code (with a timer)?
Thanks in advance for any help.
you can use mediaRecorder API .
here an simple example :
public class VideoCapture extends Activity implements OnClickListener, SurfaceHolder.Callback {
MediaRecorder recorder;
SurfaceHolder holder;
boolean recording = false;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
recorder = new MediaRecorder();
initRecorder();
setContentView(R.layout.main);
SurfaceView cameraView = (SurfaceView) findViewById(R.id.CameraView);
holder = cameraView.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
cameraView.setClickable(true);
cameraView.setOnClickListener(this);
}
private void initRecorder() {
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
CamcorderProfile cpHigh = CamcorderProfile
.get(CamcorderProfile.QUALITY_HIGH);
recorder.setProfile(cpHigh);
recorder.setOutputFile("/sdcard/videocapture_example.mp4");
recorder.setMaxDuration(50000); // 50 seconds
recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
}
private void prepareRecorder() {
recorder.setPreviewDisplay(holder.getSurface());
try {
recorder.prepare();
} catch (IllegalStateException e) {
e.printStackTrace();
finish();
} catch (IOException e) {
e.printStackTrace();
finish();
}
}
public void onClick(View v) {
if (recording) {
recorder.stop();
recording = false;
// Let's initRecorder so we can record again
initRecorder();
prepareRecorder();
} else {
recording = true;
recorder.start();
}
}
public void surfaceCreated(SurfaceHolder holder) {
prepareRecorder();
}
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
}
public void surfaceDestroyed(SurfaceHolder holder) {
if (recording) {
recorder.stop();
recording = false;
}
recorder.release();
finish();
}
}
I open it with an intent but it comes up with the red start recording button.
The exact user experience of the video-recording app will vary by app, as there are hundreds, if not thousands, of apps that can respond to Intent actions like ACTION_VIDEO_CAPTURE. For example, whether there is a "red start recording button" or not is up to the developer of the video-recording app.
Is there a way I can control the stop and start recording in code (with a timer)?
Not if you are launching a third-party app to do the video recording (e.g., ACTION_VIDEO_CAPTURE). You would have to record the video yourself, using MediaRecorder.
I am trying to Record a Video, But It's getting crash at Media Record starts and Media Record Prepare .please Help Me... Here Is My Code...
private boolean startRecording() {
camera.unlock();
try {
mediaRecorder = new MediaRecorder();
mediaRecorder.setOnErrorListener(new MediaRecorder.OnErrorListener() {
#Override
public void onError(MediaRecorder mr, int what, int extra) {
Log.i(TAG, "Error");
}
});
second=0;
minute=0;
recordCountTimer = new CountDownTimer(Long.MAX_VALUE,1000) {
#Override
public void onTick(long millisUntilFinished) {
second++;
if(second>=60){
second=0;
minute++;
}
recordCount.setText(String.format("%02d:%02d",minute,second));
}
#Override
public void onFinish() {
finish();
}
}.start();
mediaRecorder.setCamera(camera);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
Log.d(TAG, "A");
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
Log.e(TAG, "B");
mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
defaultVideoPath= FileManger.getOutputMediaFile(MEDIA_TYPE_VIDEO).getAbsolutePath();
// uriVid = Uri.parse(FileManger.getOutputMediaFile(MEDIA_TYPE_VIDEO).getAbsolutePath());
// defaultVideoPath = getRealPathFromUri(uriVid);
mediaRecorder.setOutputFile(defaultVideoPath);
mediaRecorder.setVideoSize(recordingCameraSurface.getWidth(), recordingCameraSurface.getHeight());
mediaRecorder.setVideoFrameRate(20);
Log.v(TAG, "C");
mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
mediaRecorder.setMaxFileSize(50000);
mediaRecorder.prepare();
Log.w(TAG, "D");
mediaRecorder.start();
Log.e(TAG, "E");
} catch (IOException e) {
releaseMediaRecorder();
return false;
}catch (IllegalStateException t){
releaseMediaRecorder();
return false;
}
return true;
}
It's giving like
RECORDER_OK﹕ B
MediaRecorder﹕ setOutputFormat called in an invalid state: 4
and Here I am Going to next Activity:
Intent intent = new Intent(RecordBuyPage.this,CheckAndSaveActivity.class);
intent.putExtra("VIDEOFILEPATH", defaultVideoPath);
startActivity(intent);
and in the next Activity i am getting the path null like:
player.setDataSource(getIntent().getStringExtra("VIDEOFILEPATH"));
I think My Order Of Calling Media Recorder Is Correct But it also getting trouble at:
mediarecoreder.prepare().
Please Give Some Valid Solution, I tried a lot From Stack overflow, but it's not working.... I think Video Is Not Recording, because when I passed it through intent it's taking null...
I hope you followed this link of sample code(Media Recorder)
https://github.com/googlesamples/android-MediaRecorder
and it has some bugs in it to record media in portrait mode so to fix this issue please follow this link
and in this link you will get your media path where it stored and you can easily pass it to another activity. Have a look I hope it helps you.
to get the path of media on stop capturing you can do this on your CaptureClick method
Log.d("Video file path", CameraHelper.getOutputMediaFile(
CameraHelper.MEDIA_TYPE_VIDEO).toString());
and complete button OnClickListener
public void onCaptureClick(View view) {
if (isRecording) {
// BEGIN_INCLUDE(stop_release_media_recorder)
// stop recording and release camera
mMediaRecorder.stop(); // stop the recording
releaseMediaRecorder(); // release the MediaRecorder object
mCamera.lock(); // take camera access back from MediaRecorder
// inform the user that recording has stopped
setCaptureButtonText("Capture");
isRecording = false;
releaseCamera();
Log.d("Video file path", CameraHelper.getOutputMediaFile(
CameraHelper.MEDIA_TYPE_VIDEO).toString());
// END_INCLUDE(stop_release_media_recorder)
} else {
// BEGIN_INCLUDE(prepare_start_media_recorder)
new MediaPrepareTask().execute(null, null, null);
// END_INCLUDE(prepare_start_media_recorder)
}
}
Please follow these two links provided above, it might solve your issue.
try this
public class VideoCapture extends Activity implements OnClickListener
,SurfaceHolder.Callback {
MediaRecorder recorder;
SurfaceHolder holder;
boolean recording = false;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
recorder = new MediaRecorder();
initRecorder();
setContentView(R.layout.main);
SurfaceView cameraView = (SurfaceView) findViewById(R.id.CameraView);
holder = cameraView.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
cameraView.setClickable(true);
cameraView.setOnClickListener(this);
}
private void initRecorder() {
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
CamcorderProfile cpHigh = CamcorderProfile
.get(CamcorderProfile.QUALITY_HIGH);
recorder.setProfile(cpHigh);
recorder.setOutputFile("/sdcard/videocapture_example.mp4");
recorder.setMaxDuration(50000); // 50 seconds
recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
}
private void prepareRecorder() {
recorder.setPreviewDisplay(holder.getSurface());
try {
recorder.prepare();
} catch (IllegalStateException e) {
e.printStackTrace();
finish();
} catch (IOException e) {
e.printStackTrace();
finish();
}
}
public void onClick(View v) {
if (recording) {
recorder.stop();
recording = false;
// Let's initRecorder so we can record again
initRecorder();
prepareRecorder();
} else {
recording = true;
recorder.start();
}
}
public void surfaceCreated(SurfaceHolder holder) {
prepareRecorder();
}
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
}
public void surfaceDestroyed(SurfaceHolder holder) {
if (recording) {
recorder.stop();
recording = false;
}
recorder.release();
finish();
}
}
Include Permissions in Manifest file :
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I have activity with SurfaceView, i want start and stop video record in this Activity, but i want continue record video if i go to other Activity. Now i start record video(in activity 1) and go to other Activity, when i back (to activity 1) and want stop record video, my app is freezes when called recorder.stop(); How i can fix it?
Init SurfaceView and SurfaceHolder:
SurfaceView cameraView = (SurfaceView) findViewById(R.id.surfaceView);
SurfaceHolder holder = cameraView.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
Start record video:
protected void startRecordVideo() {
if (cam == null) {
cam = Camera.open();
try {
cam.setPreviewDisplay(holder);
} catch (IOException e) {
e.printStackTrace();
}
}
recording = true;
recorder = new MediaRecorder();
recorder.setCamera(cam);
initRecorder();
prepareRecorder();
try {
cam.unlock();
} catch (RuntimeException e) {
e.printStackTrace();
}
recorder.start();
}
Stop record video (this is app freezes):
protected void stopRecordVideo() { //cam - Camera, recorder - MediaRecorder
mc.IS_RECORD = false;
recording = false;
try {
cam.lock();
recorder.stop(); //app freezes in this line (i used Log)
recorder = null;
cam.reconnect();
cam.release();
cam = null;
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (RuntimeException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
P.S. i do not use camera.startPreview(); and camera.stopPreview();
Try to wrap stopRecordVideo inside a Thread, so it doesnt block the main (UI) Thread.
If it doesnt work, take a look at this question :
Android Media Recording using threads
It seems you must do a little "hack"
I am recording a video in android using media recorder. The video is recorded nicely in phone for both front and back camera but for tablet the video is recorded nicely for back camera but for front camera it is showing blurry. This is how my recorded video looks:
my code for video recording is
private Camera getCameraInstance() {
// TODO Auto-generated method stub
Camera c = null;
try {
if (Camera.getNumberOfCameras() >= 2) {
//if you want to open front facing camera use this line
c = Camera.open(CameraInfo.CAMERA_FACING_FRONT);}
// c.setDisplayOrientation(90);
//c = Camera.open(1); // attempt to get a Camera instance
} catch (Exception e) {
// Camera is not available (in use or does not exist)
}
return c; // returns null if camera is unavailable
}
private boolean prepareMediaRecorder() {
myCamera = getCameraInstance();
mediaRecorder = new MediaRecorder();
myCamera.unlock();
mediaRecorder.setCamera(myCamera);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setProfile(CamcorderProfile
.get(CamcorderProfile.QUALITY_HIGH));
mediaRecorder.setOutputFile("/sdcard/myvideo.mp4");
//mediaRecorder.setMaxDuration(60000); // Set max duration 60 sec.
//mediaRecorder.setMaxFileSize(5000000); // Set max file size 5M
mediaRecorder.setPreviewDisplay(myCameraSurfaceView.getHolder()
.getSurface());
try {
mediaRecorder.prepare();
} catch (IllegalStateException e) {
releaseMediaRecorder();
return false;
} catch (IOException e) {
releaseMediaRecorder();
return false;
}
return true;
}
I have been playing around with mediarecorders since yesterday and I can't get around a camera error 100. I keep getting
08-13 11:23:24.952: I/System.out(2418): Going to get the camera
08-13 11:23:25.092: I/System.out(2418): This is the camera android.hardware.Camera#4051b208
08-13 11:23:25.273: I/System.out(2418): Surface was created
08-13 11:23:25.282: I/System.out(2418): Stop preview worked android.hardware.Camera#4051b208
08-13 11:23:25.282: I/System.out(2418): Surface changed
08-13 11:23:31.302: I/System.out(2418): This is the camera android.hardware.Camera#40520d20
08-13 11:23:31.345: I/System.out(2418): Trying to save picture
08-13 11:23:31.352: I/System.out(2418): About to preview
08-13 11:23:31.352: I/System.out(2418): Preview worked
08-13 11:23:31.352: I/MediaRecorderJNI(2418): prepare: surface=0x2a8198 (identity=216)
08-13 11:23:31.362: I/System.out(2418): Starting to record
08-13 11:23:32.512: W/IMediaDeathNotifier(2418): media server died
08-13 11:23:32.512: W/Camera(2418): Camera server died!
08-13 11:23:32.512: W/Camera(2418): ICamera died
08-13 11:23:32.522: I/System.out(2418): Stop preview worked android.hardware.Camera#40520d20
08-13 11:23:32.522: I/System.out(2418): Surface changed
08-13 11:23:32.592: E/Camera(2418): Error 100
I don't understand how. I released the camera before creating the mediarecorder and unlocking it. Just can't wrap my head around it. This is what I did.
public class MainActivity extends Activity {
private Camera mCamera;
private MediaRecorder mMediaRecorder;
private CameraPreview mPreview;
private static final String TAG = "Message";
public static final int MEDIA_TYPE_IMAGE = 1;
public static final int MEDIA_TYPE_VIDEO = 2;
private boolean isRecording = false;
Button captureButton;
FrameLayout preview;
FrameLayout myCameraPreview;
private MyCameraSurfaceView myCameraSurfaceView;
private MyCameraSurfaceView myCameraView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.preview);
System.out.println("Going to get the camera");
mCamera = getCameraInstance();
//mMediaRecorder = new MediaRecorder();
/* mPreview = new CameraPreview(this, mCamera);
preview = (FrameLayout) findViewById(R.id.camera_preview);
preview.addView(mPreview);*/
// setPreviewCallback(null);
myCameraSurfaceView = new MyCameraSurfaceView(this, mCamera);
myCameraPreview = (FrameLayout)findViewById(R.id.camera_preview);
myCameraPreview.addView(myCameraSurfaceView);
captureButton = (Button) findViewById(R.id.button_capture);
captureButton.setOnClickListener(
new View.OnClickListener() {
#Override
public void onClick(View v) {
if (isRecording) {
// stop recording and release camera
mMediaRecorder.stop(); // stop the recording
releaseMediaRecorder(); // release the MediaRecorder object
mCamera.lock(); // take camera access back from MediaRecorder
// inform the user that recording has stopped
captureButton.setText("Capture");
isRecording = false;
} else {
// initialize video camera
if (prepareVideoRecorder()) {
System.out.println("Starting to record");
// Camera is available and unlocked, MediaRecorder is prepared,
// now you can start recording
//releaseCamera();
mMediaRecorder.start();
// inform the user that recording has started
captureButton.setText("Stop");
isRecording = true;
} else {
// prepare didn't work, release the camera
System.out.println("Recording failed");
releaseMediaRecorder();
// inform user
}
}
}
}
);
}
public static Camera getCameraInstance(){
Camera c = null;
try {
c = Camera.open();
System.out.println("This is the camera "+c);// attempt to get a Camera instance
}
catch (Exception e){
// Camera is not available (in use or does not exist)
System.out.println("Didn't get the camera ");
}
return c; // returns null if camera is unavailable
}
private boolean prepareVideoRecorder(){
releaseCamera();
//preview.removeAllViews();
mCamera = getCameraInstance();
mMediaRecorder = new MediaRecorder();
myCameraSurfaceView.mCamera=mCamera;
//myCameraView = new MyCameraSurfaceView(this, mCamera);
//myCameraPreview = (FrameLayout)findViewById(R.id.camera_preview);
//myCameraPreview.addView(myCameraView);
// Step 1: Unlock and set camera to MediaRecorder
//mCamera.lock();
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
// Step 2: Set sources
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
// Step 3: Set a CamcorderProfile (requires API Level 8 or higher)
mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_LOW));
// Step 4: Set output file
mMediaRecorder.setOutputFile(getOutputMediaFile(MEDIA_TYPE_VIDEO).toString());
// Step 5: Set the preview output
System.out.println("About to preview");
mMediaRecorder.setPreviewDisplay(myCameraSurfaceView.getHolder().getSurface());
System.out.println("Preview worked");
// Step 6: Prepare configured MediaRecorder
try {
mMediaRecorder.prepare();
} catch (IllegalStateException e) {
Log.d(TAG, "IllegalStateException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
} catch (IOException e) {
Log.d(TAG, "IOException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
}
return true;
}
#Override
protected void onPause() {
super.onPause();
releaseMediaRecorder(); // if you are using MediaRecorder, release it first
releaseCamera(); // release the camera immediately on pause event
}
private void releaseMediaRecorder(){
if (mMediaRecorder != null) {
mMediaRecorder.reset(); // clear recorder configuration
mMediaRecorder.release(); // release the recorder object
mMediaRecorder = null;
mCamera.lock(); // lock camera for later use
}
}
private void releaseCamera(){
if (mCamera != null){
mCamera.release(); // release the camera for other applications
mCamera = null;
}
}
public class MyCameraSurfaceView extends SurfaceView implements SurfaceHolder.Callback{
private SurfaceHolder mHolder;
private Camera mCamera;
public MyCameraSurfaceView(Context context, Camera camera) {
super(context);
mCamera = camera;
// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed.
mHolder = getHolder();
mHolder.addCallback(this);
// deprecated setting, but required on Android versions prior to 3.0
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
#Override
public void surfaceChanged(SurfaceHolder holder, int format, int weight,
int height) {
// If your preview can change or rotate, take care of those events here.
// Make sure to stop the preview before resizing or reformatting it.
if (mHolder.getSurface() == null){
// preview surface does not exist
return;
}
// stop preview before making changes
try {
mCamera.stopPreview();
System.out.println("Stop preview worked "+mCamera);
} catch (Exception e){
// ignore: tried to stop a non-existent preview
System.out.println("tried to stop a non-existent preview "+mCamera);
}
// make any resize, rotate or reformatting changes here
// start preview with new settings
try {
mCamera.setPreviewDisplay(mHolder);
mCamera.startPreview();
System.out.println("Surface changed");
} catch (Exception e){
}
}
#Override
public void surfaceCreated(SurfaceHolder holder) {
// TODO Auto-generated method stub
// The Surface has been created, now tell the camera where to draw the preview.
try {
mCamera.setPreviewDisplay(holder);
mCamera.startPreview();
System.out.println("Surface was created");
} catch (IOException e) {
}
}
#Override
public void surfaceDestroyed(SurfaceHolder holder) {
// TODO Auto-generated method stub
}
}
}
I'm pretty much confused right now.
It is possible that the error is a result of a know bug with XE19.1.
After I set parameters.setRecordingHint(true)
my video camera started working again.
Hope this also help you