Git Product home page Git Product logo

mediaselector's Introduction

MediaSelector

提供android图片选择和预览功能

简介

  • 媒体资源选择库
  • 兼容版本 19 ~ 29
  • 自询问并获取相关权限

art1

使用

需要添加

    maven { url 'https://jitpack.io' }
  1. 获取媒体资源
implementation 'com.github.wzq.MediaSelector:core:x.x.x'
    ImageSource().getMediaSource(context)
  1. 打开一个带样式和功能的activity,在onActivityResult中返回选择结果
    implementation 'com.github.wzq.MediaSelector:basic:1.3.0'
    SelectorBasicActivity.open(context)
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (requestCode == MediaSelector.SELECTOR_REQ) {
            val items = data?.getParcelableArrayListExtra<MediaData>("data") ?: return
            //TODO
        }
    }

3.数据类MediaData

    data class MediaData(
        val id: String,
        val name: String, //名称
        val size: Long = 0,  //文件大小
        val orientation: Int,
        val createTime: String?,
        val dirId: String?, //文件夹ID
        val dirName: String?, //文件夹 名称
        val path: String?, //路径 尽量使用uri
        val duration: Long = -1, //视频时长
    ) : Parcelable

mediaselector's People

Contributors

wzq avatar

Stargazers

 avatar  avatar

Watchers

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