android camera fragment,CameraFragment:一个简单易于集成的Camera Fragment

CameraFragment

625332134c6f4d4600884b99daebf603.png625332134c6f4d4600884b99daebf603.png

A simple easy-to-integrate Camera Fragment for Android

CameraFragment preview directly the camera view, and provides a easy API to capture or manage the device

You can setup your own layout and control the camera using CameraFragment

625332134c6f4d4600884b99daebf603.png

CameraKit

This library works, but on some devices... errors happens, I don't have time to maintain compatibility with all device A community group was created, they created CameraKit, don't hesitate to try it !

Setup

625332134c6f4d4600884b99daebf603.png

//you can configure the fragment by the configuration builder

CameraFragment cameraFragment = CameraFragment.newInstance(new Configuration.Builder().build());

getSupportFragmentManager().beginTransaction()

.replace(R.id.content, cameraFragment, FRAGMENT_TAG)

.commit();

Actions

You can directly take a photo / video with

cameraFragment.takePhotoOrCaptureVideo(callback);

cameraFragment.takePhotoOrCaptureVideo(callback, directoryPath, fileName);

625332134c6f4d4600884b99daebf603.png

Flash can be enable / disabled ( AUTO / OFF / ON ) with

cameraFragment.toggleFlashMode();

625332134c6f4d4600884b99daebf603.png

Camera Type can be modified ( BACK / FRONT ) with

cameraFragment.switchCameraTypeFrontBack();

625332134c6f4d4600884b99daebf603.png

Camera action ( PHOTO / VIDEO ) can be modified with

cameraFragment.switchActionPhotoVideo();

625332134c6f4d4600884b99daebf603.png

And you can change the captured photo / video size with

cameraFragment.openSettingDialog();

625332134c6f4d4600884b99daebf603.png

Listeners

Result

Get back the result of the camera record / photo in the CameraFragmentResultListener

cameraFragment.setResultListener(new CameraFragmentResultListener() {

@Override

public void onVideoRecorded(byte[] bytes, String filePath) {

//called when the video record is finished and saved

startActivityForResult(PreviewActivity.newIntentVideo(MainActivity.this, filePath));

}

@Override

public void onPhotoTaken(byte[] bytes, String filePath) {

//called when the photo is taken and saved

startActivity(PreviewActivity.newIntentPhoto(MainActivity.this, filePath));

}

});

Camera Listener

cameraFragment.setStateListener(new CameraFragmentStateListener() {

//when the current displayed camera is the back

void onCurrentCameraBack();

//when the current displayed camera is the front

void onCurrentCameraFront();

//when the flash is at mode auto

void onFlashAuto();

//when the flash is at on

void onFlashOn();

//when the flash is off

void onFlashOff();

//if the camera is ready to take a photo

void onCameraSetupForPhoto();

//if the camera is ready to take a video

void onCameraSetupForVideo();

//when the camera state is "ready to record a video"

void onRecordStateVideoReadyForRecord();

//when the camera state is "recording a video"

void onRecordStateVideoInProgress();

//when the camera state is "ready to take a photo"

void onRecordStatePhoto();

//after the rotation of the screen / camera

void shouldRotateControls(int degrees);

void onStartVideoRecord(File outputFile);

void onStopVideoRecord();

});

Text

CameraFragment can ping you with the current record duration with CameraFragmentTextListener

Widgets

CameraFragment comes with some default views

RecordButton, MediaActionSwitchView, FlashSwitchView, CameraSwitchView, CameraSettingsView

625332134c6f4d4600884b99daebf603.png

Download

625332134c6f4d4600884b99daebf603.png

In your module 625332134c6f4d4600884b99daebf603.png

compile 'com.github.florent37:camerafragment:1.0.10'

Community

This library works, but on some devices... errors happens, I don't have time to maintain compatibility with all device A community group was created, they created CameraKit, don't hesitate to try it !

Credits

625332134c6f4d4600884b99daebf603.png

625332134c6f4d4600884b99daebf603.png

625332134c6f4d4600884b99daebf603.png

625332134c6f4d4600884b99daebf603.png

License

Copyright 2017 florent37, Inc.

Licensed under the Apache License, Version 2.0 (the "License");

you may not use this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值