Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何判断选择的是图片还是视频格式呢 #61

Closed
RookieExaminer opened this issue Jun 4, 2019 · 3 comments
Closed

如何判断选择的是图片还是视频格式呢 #61

RookieExaminer opened this issue Jun 4, 2019 · 3 comments

Comments

@RookieExaminer
Copy link

原库Matisse 可根据选择后的后缀格式进行判断 比如 123.jpg
但是这个库,并没有带格式的后缀了 123

@RookieExaminer
Copy link
Author

现在用RxImagePicker 里知乎的ui 从返回的t.uri 里判断是否包含 images 或 video,来判断是否是图片还是视频,不知道这种方法会不会有问题

@qingmei2
Copy link
Owner

qingmei2 commented Jun 6, 2019

@RookieExaminer

可以考虑为知乎和微信主题的返回结果,增加对应的字段以告知媒体资源的类型(视频、图片、音频),该功能预计会在下版本更新

@qingmei2
Copy link
Owner

qingmei2 commented Jun 9, 2019

@RookieExaminer

该功能2.5.0版本更新,知乎微信 主题增加了返回 资源文件类型 的字段:

代码示例:

val mimeType = result.getStringExtra("EXTRA_OPTIONAL_MIME_TYPE", "")
Log.d(TAG, "mime types: $mimeType")

使用方式参考类似代码:

val isImage: Boolean
      get() = if (mimeType == null) false else mimeType == MimeType.JPEG.toString()
           || mimeType == MimeType.PNG.toString()
           || mimeType == MimeType.GIF.toString()
           || mimeType == MimeType.BMP.toString()
           || mimeType == MimeType.WEBP.toString()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants