Code example for MediaRecorder: Recording audio and video

Methods: preparereleaseresetsetPreviewDisplaystart

0
        return reallyStart(); 
    } 
 
    private boolean reallyStart() { 
 
        mMediaRecorder.setPreviewDisplay( mCameraSurfaceHolder.getSurface() );
        try { 
            mMediaRecorder.prepare();
        } catch ( IllegalStateException e ) {
            releaseMediaRecorder(); 
            Log.d( "TEAONLY", "JAVA:  camera prepare illegal error" );
            return false; 
        } catch ( IOException e ) {
            releaseMediaRecorder(); 
            Log.d( "TEAONLY", "JAVA:  camera prepare io error" );
            return false; 
        } 
 
        try { 
            mMediaRecorder.start();
        } catch ( Exception e ) {
            releaseMediaRecorder(); 
            Log.d( "TEAONLY", "JAVA:  camera start error" );
            return false; 
        } 
 
        return true; 
    } 
 
    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
            mCamera.startPreview();
        } 
        mMediaRecorder = null;