Android mediarecorder stop failed Android mediarecorder stop failed android android

Android mediarecorder stop failed


You may catch a RuntimeException at the MediaRecorder.stop() method.

Example:

MediaRecorder mRecorder = new MediaRecorder();File mFile = new File("The output file's absolutePath");... //config the mRecordermRecorder.setOutputFile(mFile.getAbsolutePath());... //prepare() ...mRecorder.start();try {    mRecorder.stop();} catch(RuntimeException e) {    mFile.delete();  //you must delete the outputfile when the recorder stop failed.} finally {    mRecorder.release();    mRecorder = null;}


add following in your SurfaceCreated(SurfaceHolder holder):

CamcorderProfile camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);  //get your own profile    Camera.Parameters parameters = mCamera.getParameters();   parameters.setPreviewSize(camcorderProfile.videoFrameWidth,camcorderProfile.videoFrameHeight);    mCamera.setParameters(parameters);