private void initViews() {
   btn_switch = (Button) findViewById(R.id.switch_btn);
   btn_switch.setOnClickListener(this);
   btn_switch.setVisibility(View.VISIBLE);
   mVideoView = (VideoView) findViewById(R.id.mVideoView);
   btnStart = (ImageView) findViewById(R.id.recorder_start);
   btnStop = (ImageView) findViewById(R.id.recorder_stop);
   btnStart.setOnClickListener(this);
   btnStop.setOnClickListener(this);
   mSurfaceHolder = mVideoView.getHolder();
   mSurfaceHolder.addCallback(this);
   mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
   chronometer = (Chronometer) findViewById(R.id.chronometer);
 }
  @SuppressLint("NewApi")
  private boolean initCamera() {
    try {
      if (frontCamera == 0) {
        mCamera = Camera.open(CameraInfo.CAMERA_FACING_BACK);
      } else {
        mCamera = Camera.open(CameraInfo.CAMERA_FACING_FRONT);
      }
      Parameters camParams = mCamera.getParameters();
      mCamera.lock();
      mSurfaceHolder = mVideoView.getHolder();
      mSurfaceHolder.addCallback(this);
      mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
      mCamera.setDisplayOrientation(90);

    } catch (RuntimeException ex) {
      EMLog.e("video", "init Camera fail " + ex.getMessage());
      return false;
    }
    return true;
  }
  @SuppressLint("NewApi")
  public void switchCamera() {

    if (mCamera == null) {
      return;
    }
    if (Camera.getNumberOfCameras() >= 2) {
      btn_switch.setEnabled(false);
      if (mCamera != null) {
        mCamera.stopPreview();
        mCamera.release();
        mCamera = null;
      }

      switch (frontCamera) {
        case 0:
          mCamera = Camera.open(CameraInfo.CAMERA_FACING_FRONT);
          frontCamera = 1;
          break;
        case 1:
          mCamera = Camera.open(CameraInfo.CAMERA_FACING_BACK);
          frontCamera = 0;
          break;
      }
      try {
        mCamera.lock();
        mCamera.setDisplayOrientation(90);
        mCamera.setPreviewDisplay(mVideoView.getHolder());
        mCamera.startPreview();
      } catch (IOException e) {
        mCamera.release();
        mCamera = null;
      }
      btn_switch.setEnabled(true);
    }
  }