本文整理匯總了Java中android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK屬性的典型用法代碼示例。如果您正苦於以下問題:Java CameraInfo.CAMERA_FACING_BACK屬性的具體用法?Java CameraInfo.CAMERA_FACING_BACK怎麽用?Java CameraInfo.CAMERA_FACING_BACK使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.hardware.Camera.CameraInfo
的用法示例。
在下文中一共展示了CameraInfo.CAMERA_FACING_BACK屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findBackFacingCamera
private int findBackFacingCamera()
{
int cameraId = -1;
int numberOfCameras = Camera.getNumberOfCameras();
for (int i = 0; i < numberOfCameras; i++)
{
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(i, info);
if (info.facing == CameraInfo.CAMERA_FACING_BACK)
{
Log.d(TAG_NAME, "Camera found");
cameraId = i;
break;
}
}
return cameraId;
}
示例2: onCreate
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create a container that will hold a SurfaceView for camera previews
mPreview = new Preview(this.getActivity());
// Find the total number of cameras available
mNumberOfCameras = Camera.getNumberOfCameras();
// Find the ID of the rear-facing ("default") camera
CameraInfo cameraInfo = new CameraInfo();
for (int i = 0; i < mNumberOfCameras; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
mCurrentCamera = mDefaultCameraId = i;
}
}
setHasOptionsMenu(mNumberOfCameras > 1);
}
示例3: flipCamera
public void flipCamera() {
if (Camera.getNumberOfCameras() > 1) {
cameraId = cameraId == CameraInfo.CAMERA_FACING_BACK
? CameraInfo.CAMERA_FACING_FRONT
: CameraInfo.CAMERA_FACING_BACK;
onPause();
onResume();
TextSecurePreferences.setDirectCaptureCameraId(getContext(), cameraId);
}
}
示例4: findBackFacingCamera
private int findBackFacingCamera() {
cameraId = -1;
// Search for the back facing camera
// get the number of cameras
int numberOfCameras = Camera.getNumberOfCameras();
// for every camera check
for (int i = 0; i < numberOfCameras; i++) {
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(i, info);
if (info.facing == CameraInfo.CAMERA_FACING_BACK) {
cameraId = i;
cameraFront = false;
break;
}
}
return cameraId;
}
示例5: getCameraId
private int getCameraId() {
CameraInfo ci = new CameraInfo();
for (int i = 0; i < Camera.getNumberOfCameras(); i++) {
Camera.getCameraInfo(i, ci);
if (ci.facing == CameraInfo.CAMERA_FACING_BACK)
return i;
}
return -1; // No camera found
}
示例6: CameraTrans
private void CameraTrans(SurfaceHolder mholder) {
// 切換前後攝像頭
int cameraCount = 0;
CameraInfo cameraInfo = new CameraInfo();
cameraCount = Camera.getNumberOfCameras();// 得到攝像頭的個數
for (int i = 0; i < cameraCount; i++) {
Camera.getCameraInfo(i, cameraInfo);// 得到每一個攝像頭的信息
if (startFontCamera) {
// 現在是後置,變更為前置
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT) {
/**
* 記得釋放camera,方便其他應用調用
*/
releaseCamera();
// 打開當前選中的攝像頭
mcamera = Camera.open(i);
startFontCamera = false;
setStartPreview(mcamera, mholder);
break;
}
} else {
// 現在是前置, 變更為後置
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
/**
* 記得釋放camera,方便其他應用調用
*/
releaseCamera();
mcamera = Camera.open(i);
startFontCamera = true;
setStartPreview(mcamera, mholder);
break;
}
}
}
}
示例7: hasCamera
@Override
public boolean hasCamera(final int facing) {
if (facing == CameraInfo.CAMERA_FACING_BACK) {
return hasCameraSupport();
}
return false;
}
示例8: openCameraFacing
@Override
public Camera openCameraFacing(final int facing) {
if (facing == CameraInfo.CAMERA_FACING_BACK) {
return Camera.open();
}
return null;
}
示例9: getDefaultCameraID
public static int getDefaultCameraID() {
int camerasCnt = getAvailableCamerasCount();
int defaultCameraID = 0;
CameraInfo cameraInfo = new CameraInfo();
for (int i = 0; i < camerasCnt; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
defaultCameraID = i;
}
}
return defaultCameraID;
}
示例10: switchCamera
/** Switch between the front facing and the back facing camera of the phone.
* If {@link #startPreview()} has been called, the preview will be briefly interrupted.
* If {@link #start()} has been called, the stream will be briefly interrupted.
* You should not call this method from the main thread if you are already streaming.
* @throws IOException
* @throws RuntimeException
**/
public void switchCamera() throws RuntimeException, IOException {
if (Camera.getNumberOfCameras() == 1) throw new IllegalStateException("Phone only has one camera !");
boolean streaming = mStreaming;
boolean previewing = mCamera!=null && mCameraOpenedManually;
mCameraId = (mCameraId == CameraInfo.CAMERA_FACING_BACK) ? CameraInfo.CAMERA_FACING_FRONT : CameraInfo.CAMERA_FACING_BACK;
setCamera(mCameraId);
stopPreview();
mFlashEnabled = false;
if (previewing) startPreview();
if (streaming) start();
}
示例11: getDefaultCameraID
public static int getDefaultCameraID() {
int camerasCnt = getAvailableCamerasCount();
int defaultCameraID = 0;
CameraInfo cameraInfo = new CameraInfo();
for (int i=0; i <camerasCnt; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
defaultCameraID = i;
}
}
return defaultCameraID;
}
示例12: hasCamera
@Override
public boolean hasCamera(final int facing) {
if (facing == CameraInfo.CAMERA_FACING_BACK) {
return hasCameraSupport();
}
return false;
}
示例13: isRearCamera
public boolean isRearCamera() {
return cameraId == CameraInfo.CAMERA_FACING_BACK;
}
示例14: onClick
@Override
public void onClick(View v) {
//下一步
if (v.getId() == R.id.recorder_next) {
if (isRecordingStarted) {
rec = false;
saveRecording();
} else
initiateRecording(false);
} else if (v.getId() == R.id.recorder_flashlight) {
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) {
//showToast(this, "不能開啟閃光燈");
return;
}
//閃光燈
if (isFlashOn) {
isFlashOn = false;
flashIcon.setSelected(false);
cameraParameters.setFlashMode(Parameters.FLASH_MODE_OFF);
} else {
isFlashOn = true;
flashIcon.setSelected(true);
cameraParameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
}
mCamera.setParameters(cameraParameters);
} else if (v.getId() == R.id.recorder_frontcamera) {
//轉換攝像頭
cameraSelection = ((cameraSelection == CameraInfo.CAMERA_FACING_BACK) ? CameraInfo.CAMERA_FACING_FRONT : CameraInfo.CAMERA_FACING_BACK);
initCameraLayout();
if (cameraSelection == CameraInfo.CAMERA_FACING_FRONT)
flashIcon.setVisibility(View.GONE);
else {
flashIcon.setVisibility(View.VISIBLE);
if (isFlashOn) {
cameraParameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
mCamera.setParameters(cameraParameters);
}
}
} else if (v.getId() == R.id.recorder_cancel) {
if (recording)
showCancellDialog();
else
videoTheEnd(false);
}
}
示例15: getCameraInfo
@Override
public void getCameraInfo(final int cameraId, final CameraHelper.CameraInfo2 cameraInfo) {
cameraInfo.facing = CameraInfo.CAMERA_FACING_BACK;
cameraInfo.orientation = 90;
}