Giter Site home page Giter Site logo

aer874475222 / albumcamerarecorder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zhongjhatc/albumcamerarecorder

0.0 1.0 0.0 32.78 MB

一个高效的多媒体支持操作库,可多方面的简单配置操作相册、拍照、录制、录音等功能。也支持配套使用的展示图片、视频、音频的九宫格功能。

License: MIT License

Java 100.00%

albumcamerarecorder's Introduction

AlbumCameraRecorder

MinSdk License

目前已经投入到正式项目中使用。

有任何建议或者想添加的功能,都可提在Issues

中文

一个高效的多媒体支持操作库,可多方面的简单配置操作拍照、相册、录制、录音等功能。

也支持配套使用的展示图片、视频、音频的九宫格功能。

本开源库的部分代码来自Matisse.

非常感谢知乎提供的这么棒的开源项目!

特性

  • 支持自定义样式.支持更换里面的相关按钮.
  • 支持相册、录制、录音等多个嵌套功能,并且也可以通过配置只设置显示一个.
  • 丰富的回调接口和调试信息,可利用现有API实现丰富的效果.

X版本分支

引入

Step 1. Add the JitPack repository to your build file

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

Step 2. Add the dependency

dependencies {
     implementation 'com.github.zhongjhATC.AlbumCameraRecorder:albumCameraRecorderCommon:1.0.18'        // 公共库,必须使用此库
     implementation 'com.github.zhongjhATC.AlbumCameraRecorder:multilibrary:1.0.18'      // 核心lib,调用显示相册、录屏、录音等
     implementation 'com.github.zhongjhATC.AlbumCameraRecorder:progresslibrary:1.0.18' // 配套使用,主要用于获取数据后进行相关显示,相应的上传进度显示,如果你只需要获取照片录像录音等数据,自行写获取后呈现方式,可以不需要是用这个
}

快照

市场上常用手机兼容测试

100%通过兼容测试报告.

使用

启动多媒体相关功能

    // 拍摄有关设置
    CameraSetting cameraSetting = new CameraSetting();
    cameraSetting.mimeTypeSet(MimeType.ofAll());// 支持的类型:图片,视频

    // 相册
    AlbumSetting albumSetting = new AlbumSetting(true)
            .mimeTypeSet(MimeType.ofAll())// 支持的类型:图片,视频
            .countable(true)// 是否显示多选图片的数字
            .addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K))// 自定义过滤器
            .originalEnable(true)// 开启原图
            .maxOriginalSize(10); // 最大原图size,仅当originalEnable为true的时候才有效

    // 录音机
    RecorderSetting recorderSetting = new RecorderSetting();

    // 全局
    GlobalSetting globalSetting = MultiMediaSetting.from(MainSimpleActivity.this).choose(MimeType.ofAll());

    if (mBinding.cbAlbum.isChecked())
        // 开启相册功能
        globalSetting.albumSetting(albumSetting);
    if (mBinding.cbCamera.isChecked())
        // 开启拍摄功能
        globalSetting.cameraSetting(cameraSetting);
    if (mBinding.cbRecorder.isChecked())
        // 开启录音功能
        globalSetting.recorderSetting(recorderSetting);

    globalSetting
            .setOnMainListener(errorMessage -> Toast.makeText(MainSimpleActivity.this.getApplicationContext(), "自定义失败信息:录音已经达到上限", Toast.LENGTH_LONG).show())
            .allStrategy(new SaveStrategy(true, "com.zhongjh.cameraapp.fileprovider", "AA/test"))// 设置路径和7.0保护路径等等
            .imageEngine(new Glide4Engine())    // for glide-V4
            .maxSelectablePerMediaType(5 - alreadyImageCount, 1 - alreadyVideoCount, 1 - alreadyAudioCount)// 最大10张图片或者最大1个视频
            .forResult(REQUEST_CODE_CHOOSE);

获取相关返回的数据

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode != RESULT_OK)
        return;
    switch (requestCode) {
        case REQUEST_CODE_PREVIEW:
            ```
        case REQUEST_CODE_CHOOSE:
            // 获取类型,根据类型设置不同的事情
            switch (MultiMediaSetting.obtainMultimediaType(data)) {
                case MultimediaTypes.PICTURE:
                    // 图片
                    List<String> path = MultiMediaSetting.obtainPathResult(data);
                    mBinding.mplImageList.addImagesStartUpload(path);
                    break;
                case MultimediaTypes.VIDEO:
                    // 录像
                    List<String> videoPath = MultiMediaSetting.obtainPathResult(data);
                    mBinding.mplImageList.addVideoStartUpload(videoPath);
                    break;
                case MultimediaTypes.AUDIO:
                    // 语音
                    RecordingItem recordingItem = MultiMediaSetting.obtainRecordingItemResult(data);
                    mBinding.mplImageList.addAudioStartUpload(recordingItem.getFilePath(), recordingItem.getLength());
                    break;
                case MultimediaTypes.BLEND:
                    // 混合类型,意思是图片可能跟录像在一起.
                    mBinding.mplImageList.addImagesStartUpload(MultiMediaSetting.obtainPathResult(data));
                    break;
            }
            break;
    }
}

如果你需要用到九宫格展览数据,具体可以看相关代码.

相关API,更多API和支持持续丰富加入

如果你使用展示的九宫库,那么下面这些api对你也有用

历史更新

从1.0.1版本开始总结的历史更新.

apk直接体验下载

喜欢的麻烦在顶部点个star

albumcamerarecorder's People

Contributors

aaatttcccc avatar zhongjhatc avatar

Watchers

 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.