Code example for Camera

Methods: getParameterssetParametersunlock

0
	 
 
	    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.setMaxDuration(600000);
	        fileUri = getOutputMediaFile();
	    	mrec.setOutputFile(fileUri);
 
	        mrec.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
	        mrec.setPreviewDisplay(surfaceHolder.getSurface());
	        
	        mrec.prepare();
	        mrec.start();
	    } 
 
	    protected void stopRecording() { 
	        mrec.stop();
	        mrec.release();
	        mCamera.release();
            chronometer.stop();
	    } 
 
	    private void releaseMediaRecorder(){ 
	        if (mrec != null) {
	            mrec.reset();   // clear recorder configuration
	            mrec.release(); // release the recorder object
	            mrec = null;
	            mCamera.lock();           // lock camera for later use
	        } 
	    } 
 
	    private void releaseCamera(){ 
	        if (mCamera != null){
	            mCamera.release();        // release the camera for other applications
	            mCamera = null;
	        } 
	    } 
 
	    @Override 
	    public void surfaceChanged(SurfaceHolder holder, int format, int width,
	            int height) {
	    } 
 
	    @Override 
	    public void surfaceCreated(SurfaceHolder holder) {
	     
	    	  
	        if (mCamera != null){
	        	Camera.Parameters params = mCamera.getParameters();
	            mCamera.setParameters(params);
	        } 
	        else { 
	            Toast.makeText(getApplicationContext(), "Camera not available!", Toast.LENGTH_LONG).show();
	            finish();
	        }