Coder Social home page Coder Social logo

ldlywt / jcamera Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jxj2118/jcamera

0.0 0.0 0.0 19.4 MB

This is Android CameraActivity,Imitation WeChat Camera Android 仿微信视频拍摄 支持触摸拍摄 长按拍摄

License: MIT License

Kotlin 80.07% Java 19.93%

jcamera's Introduction

JCamera

Platform API

This is Android CameraActivity,Imitation WeChat Camera

Android 仿微信视频拍摄 支持触摸拍摄 长按拍摄,采用camera2,需要API>21 后续考虑支持API>18

解决前置摄像头镜像问题,视频压缩采用了MasayukiSuda 的 https://github.com/MasayukiSuda/Mp4Composer-android ,会在原视频输出后占用600-700ms压缩及旋转视频

支持一步调用 支持AndroidX 本库自身支持6.0+自主动态获取权限 以及 7.0+provider配置

JPG

GIF


视频拍摄
video

图片拍摄
photo

Demo

扫码下载
点击下载

Version

2019-11-25 V1.0.4 com.android.tools.build:gradle:3.4.2 -> 3.5.2 , 修复视频处理前可点击确定的BUG, 修复按钮时长与录制时长不匹配的BUG
2019-9-17 V1.0.2 增加视频质量设置,解决录像未完成销毁Activity崩溃的BUG
2019-8-13 V1.0.1 优化尺寸匹配算法,多摄像头匹配,解决华为设备崩溃
2019-5-30 V1.0.0

Gradle

Step 1. Add the JitPack repository to your build file

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
        implementation 'com.github.jxj2118:JCamera:v1.0.4'
}

Step 3. Need Open DataBinding (PS. Follow-up consideration remove)

android {
        ...
        dataBinding {
                enabled true
        }
}

Usage

Open CameraActivity

    //如不设置 会默认打开上一次配置的结果
        JCamera.instance
            //.openPreCamera()// 是否打开为前置摄像头
            .allowPhoto(true)// 是否允许拍照 默认允许
            .allowRecord(true)// 是否允许录像 默认允许
            .setMaxRecordTime(3)//最长录像时间 秒
            .setRecordQuality(30)//设置视频质量 1-100 默认30
            .start(this,PHOTO_OR_VIDEO_FOR_CAMERA)//PHOTO_OR_VIDEO_FOR_CAMERA 请求码 回调时可用

Capture Rusult

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
            super.onActivityResult(requestCode, resultCode, data)
            if (resultCode == Activity.RESULT_OK &&  requestCode == PHOTO_OR_VIDEO_FOR_CAMERA){
                data?.let {
                    // JCamera.resultIsImg(data) 返回是否为图片
                    if (JCamera.resultIsImg(data)){
                        // JCamera.getResultPath(data) 获取结果路径
                        text.text = "Image Path:\n${JCamera.getResultPath(data)}"
                    }else{
                        text.text = "Video Path:\n${JCamera.getResultPath(data)}"
                    }
                }
            }
        }

Builder Method

method description
openPreCamera 打开前置摄像头,默认打开上一次打开的摄像头
setMaxRecordTime 最大录制时间,单位 秒
allowRecord 是否允许录像
allowPhoto 是否允许拍照

PS. 所有设置 会默认打开上一次配置的结果

References And Special Thanks to

License

MIT License

jcamera's People

Contributors

jxj2118 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.