照相機,我自己寫的代碼:
mMediaRecorderVideo=new MediaRecorder();
mCamera=Camera.open();
mCamera.setDisplayOrientation(90);
mCamera.unlock();
mMediaRecorderVideo.setCamera(mCamera);
mMediaRecorderVideo.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
mMediaRecorderVideo.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
mMediaRecorderVideo.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
使用設備的默認相機,但是如果有前置相機需要設置,應該怎麼檢測?謝謝
int numCameras= Camera.getNumberOfCameras();
for(int i=0;i<numCameras;i++){
Camera.CameraInfo info = new CameraInfo();
Camera.getCameraInfo(i, info);
if(CAMERA_FACING_FRONT == info.facing){
return true;
}
}
return false;
如果你還要得到前置相機的數量,那麼在return
中返回i,0返回not found
。