4

我想知道,是否可以取消媒体录制。取消我的意思是不要保存它。目前我正在通过这样做开始录制:

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!!");
}

并保存并停止它:

protected void stopRecording() {    
    mrec.stop();
    mrec.release();
    mCamera.release();     
}

我想做两个按钮。一种用于保存媒体文件(调用 stopRecording())。还有一秒钟取消和删除媒体录制。这甚至可能吗?如果是,如何?

4

1 回答 1

9

只需删除创建的文件

protected void stopAndDelete(){
    stopRecording();
    File file = new File(Environment.getExternalStorageDirectory() +
        "/TrouwApp/"  + date + "_" + videonr+ ".3gp");
    file.delete();
}
于 2013-08-27T14:00:21.330 回答