I was wonderinging, is it possible to cancel a media recording. By cancel I mean do not save it. Currently I am starting a recording by doing this:
protected void startRecording() throws IOException
{
mrec = new MediaRecorder(); // Works well
mCamera.unlock();
mrec.setCamera(mCamera);
mrec.setPreviewDisplay(surfaceHolder.getSurface());
mrec.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mrec.setAudioSource(MediaRecorder.AudioSource.MIC);
mrec.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
mrec.setPreviewDisplay(surfaceHolder.getSurface());
File picDirectory = new File(Environment.getExternalStorageDirectory() +"/TrouwApp");
picDirectory.mkdirs();
mrec.setOutputFile( Environment.getExternalStorageDirectory() +"/TrouwApp/" + date + "_" + videonr+ ".3gp");
mrec.prepare();
mrec.start();
Log.d(TAG, "Recording started!!");
}
And save and stop it with:
protected void stopRecording() {
mrec.stop();
mrec.release();
mCamera.release();
}
I want to make two buttons. One to save the media file(calling stopRecording()). And a second to cancel and delete the media recording. Is this even possible? If yes, how?
Just delete created file
protected void stopAndDelete(){
stopRecording();
File file = new File(Environment.getExternalStorageDirectory() +
"/TrouwApp/" + date + "_" + videonr+ ".3gp");
file.delete();
}