Code Monkey home page Code Monkey logo

haoyubihai / albumcamerarecorder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zhongjhatc/albumcamerarecorder

0.0 0.0 0.0 33.68 MB

🔥一个高效的多媒体支持操作库,可多方面的简单配置操作相册、拍照、录制、录音等功能。也支持配套使用的展示图片、视频、音频的九宫格功能。 (An efficient multimedia support operation library, can be a variety of simple configuration operation album, photo, recording, recording and other functions.Also support supporting the use of the display of pictures, video, audio of the nine grid function.)

License: MIT License

Java 100.00%

albumcamerarecorder's Introduction

AlbumCameraRecorderX

MinSdk License

This release is an offshoot of the AndroidX release.Any version number followed by an X is based on the AndroidX version.

At present, it has been put into use in the formal project.

If you have any suggestions or want to add functions, you can put forward on Issues

An efficient multimedia support operation library, can be a variety of simple configuration operation photo, album, recording, recording and other functions.

Also support supporting the use of the display of pictures, video, audio 9 grid function.

Part of the code for this open source library comes from Matisse.

Thank you very much Zhihu for providing such a great open source project!

Non-X version branching

A non-X library version, no longer maintained(https://github.com/zhongjhATC/AlbumCameraRecorder/tree/master)

peculiarity

  • Support for custom styles. Support to change the relevant buttons inside.
  • Support album, recording, recording and other functions in one (similar to Douyin, etc.), and you can configure only one of the functions independently.
  • While there are many features, some libraries can be introduced as required
  • Rich callback interface and debugging information, using the existing API to achieve a rich effect.
  • Strong compatibility, whether the lower version of 4.1 or the current latest version of Android 11, has been carried out related compatibility processing
  • Support all image reading and processing customization, such as custom Glide, Fresco, etc
  • Support to select pictures from albums
  • Supports photo albums to select different folders according to mobile phone files
  • Strong customization, support a variety of maximum selection of how many pictures, videos, and so on, also support only display custom file size
  • Support custom album style, color, size and so on
  • Support flash and front and rear camera switching when taking photos
  • Support double finger touch to zoom in and out when recording and photographing, and single finger sliding up and down to control brightness
  • recording, taking photos, pressing buttons, all of the UI is customizable, all SVG images are good for handling animation details
  • Recording support for segment recording, video editing will be added in the future
  • Image editing supports color graffiti, input text, Mosaic processing, rotation, cropping and other processing
  • Support recording processing
  • All recorded photos are compressed
  • Version after 1.0.19x is compatible with Android Q version, if you want to keep your project SDK28, you can only keep 1.0.18x

import

Step 1. Add the JitPack repository to your build file

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

Step 2. Add the dependency

dependencies {
     // Public library, which must be used
     implementation 'com.github.zhongjhATC.AlbumCameraRecorder:albumCameraRecorderCommon:1.0.32X'
     // Core lib, call display album, recording screen, recording, etc
     implementation 'com.github.zhongjhATC.AlbumCameraRecorder:multilibrary:1.0.32X'
     // Supporting use, mainly used to obtain data after the relevant display, the corresponding upload progress display, if you only need to obtain photos, video, audio and other data, their own code to obtain the data after the presentation, you can not need to use this
     implementation 'com.github.zhongjhATC.AlbumCameraRecorder:progresslibrary:1.0.32X'
     // Supporting the use of editing pictures
     implementation 'com.github.zhongjhATC.AlbumCameraRecorder:imageedit:1.0.32X'
     // Supporting the use of editing video
     implementation 'com.github.zhongjhATC.AlbumCameraRecorder:videoedit:1.0.32X'
}

snapshoot

Compatibility testing of mobile phones is commonly used in the market

100% throughCompatibility Test Report.

use

Enable multimedia related functions

    // Shooting Related Settings
    CameraSetting cameraSetting = new CameraSetting();
    // Types supported: picture, video
    cameraSetting.mimeTypeSet(MimeType.ofAll());

    // album
    mAlbumSetting = new AlbumSetting(false)
            // Types supported: picture, video
            .mimeTypeSet(MimeType.ofAll())
            // Whether to display the number of multiple selected images
            .countable(true)
            // Custom filter
            .addFilter(new GifSizeFilter(320, 320, 5 * BaseFilter.K * BaseFilter.K))
            // Open the original
            .originalEnable(true)
            // Maximum original size, valid only if originalEnable is true
            .maxOriginalSize(10);

    // recorder
    RecorderSetting recorderSetting = new RecorderSetting();

    // globalSetting
    mGlobalSetting = MultiMediaSetting.from(MainSimpleActivity.this).choose(MimeType.ofAll());

    if (mBinding.cbAlbum.isChecked()){
        // Open the album function
        mGlobalSetting.albumSetting(mAlbumSetting);
    }
    if (mBinding.cbCamera.isChecked()){
        // Turn on the shooting function
        mGlobalSetting.cameraSetting(cameraSetting);
    }
    if (mBinding.cbRecorder.isChecked()){
        // Enable recording
        mGlobalSetting.recorderSetting(recorderSetting);
    }

    mGlobalSetting
            .setOnMainListener(errorMessage -> {
                Log.d(TAG, errorMessage);
                Toast.makeText(MainSimpleActivity.this.getApplicationContext(), errorMessage, Toast.LENGTH_LONG).show();
            })
            // Set paths and 7.0 protection paths, and so on
            .allStrategy(new SaveStrategy(true, "com.zhongjh.cameraapp.fileprovider", "aabb"))
            // for glide-V4
            .imageEngine(new Glide4Engine())
            // Maximum 10 images or maximum 1 video
            .maxSelectablePerMediaType(5 - alreadyImageCount, 1 - alreadyVideoCount, 1 - alreadyAudioCount)
            .forResult(REQUEST_CODE_CHOOSE);

Gets the relevant returned data

@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:
            // Gets the type and sets different things according to the type
            switch (MultiMediaSetting.obtainMultimediaType(data)) {
                case MultimediaTypes.PICTURE:
                    // picture
                    List<String> path = MultiMediaSetting.obtainResult(data);
                    mBinding.mplImageList.addImagesStartUpload(path);
                    break;
                case MultimediaTypes.VIDEO:
                    // video
                    List<String> videoPath = MultiMediaSetting.obtainResult(data);
                    mBinding.mplImageList.addVideoStartUpload(videoPath);
                    break;
                case MultimediaTypes.AUDIO:
                    // voice
                    RecordingItem recordingItem = MultiMediaSetting.obtainRecordingItemResult(data);
                    mBinding.mplImageList.addAudioStartUpload(recordingItem.getFilePath(), recordingItem.getLength());
                    break;
                case MultimediaTypes.BLEND:
                    // Mixed type, which means the image may accompany the video.
                    List<Uri> blends = MultiMediaSetting.obtainResult(data);
                    List<Uri> images = new ArrayList<>();
                    List<Uri> videos = new ArrayList<>();
                    // Type of circular judgment
                    for (Uri uri : blends) {
                        DocumentFile documentFile = DocumentFile.fromSingleUri(getBaseContext(), uri);
                        if (documentFile.getType().startsWith("image")) {
                            images.add(uri);
                        } else if (documentFile.getType().startsWith("video")) {
                            videos.add(uri);
                        }
                    }
                    // Upload pictures and videos separately
                    mBinding.mplImageList.addUrisStartUpload(images);
                    mBinding.mplImageList.addVideoStartUpload(videos);
                    break;
            }
            break;
    }
}

If you need to use the data of the nine-grid exhibition, you can see A code for details.

Related APIs, more APIs and support for continuous enrichment added

If you use the shown library, the following APIs are also useful for you

History update

History update.

Write in the last

  1. If you think it works, give me a Star(GitHub

  2. If you find any BUG, please leave a comment or leave a Issues(Issues

  3. Any reprint please indicate the source

albumcamerarecorder's People

Contributors

aaatttcccc avatar zhongjhatc 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.