AbedElazizShe / LightCompressor

A powerful and easy-to-use video compression library for android uses MediaCodec API.
Apache License 2.0
491 stars 116 forks source link

xaiomi 9 about content://com.android.providers.media.documents/document/video%3A835951 #196

Open mobilewhj opened 2 months ago

mobilewhj commented 2 months ago

about use

mVideoAlbumLauncher.launch( PickVisualMediaRequest( ActivityResultContracts.PickVisualMedia.VideoOnly ) )

method return uri similar to content://com.android.providers.media.documents/document/video%3A835951。 I think a fileName conversion should be done.You can refer to this example。https://github.com/iPaulPro/aFileChooser/blob/master/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java#L185 。 I used an extension function in the project.

fun Uri.parseFileName(context: Context): String? = if (DocumentsContractCompat.isDocumentUri(context, this)) { DocumentFile.fromSingleUri(context, this)?.name } else { pathSegments.last() }

I think it can be more comprehensive, so please consider it, thank you.