Skip to content
Snippets Groups Projects
Commit cf485c7a authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Sanity check on Uri retrieval

parent c2dd212f
No related branches found
No related tags found
No related merge requests found
......@@ -280,13 +280,16 @@ object MediaUtils : CoroutineScope {
fun getMediaTitle(mediaWrapper: MediaWrapper) = mediaWrapper.title ?: FileUtils.getFileNameFromPath(mediaWrapper.location)!!
fun getContentMediaUri(data: Uri): Uri {
fun getContentMediaUri(data: Uri)= try {
VLCApplication.getAppContext().contentResolver.query(data,
arrayOf(MediaStore.Video.Media.DATA), null, null, null)?.use {
val columnIndex = it.getColumnIndexOrThrow(MediaStore.Video.Media.DATA)
if (it.moveToFirst()) return AndroidUtil.PathToUri(it.getString(columnIndex)) ?: data
if (it.moveToFirst()) AndroidUtil.PathToUri(it.getString(columnIndex)) ?: data else data
}
return data
} catch (e: SecurityException) {
data
} catch (e: IllegalArgumentException) {
data
}
private fun getMediaString(ctx: Context?, id: Int): String {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment