android 5.0~9.0 亲测可用
val videoIntent = Intent(ACTION_PICK, MediaStore.Video.Media.EXTERNAL_CONTENT_URI)
startActivityForResult(videoIntent, PICK_VIDEO)
if (requestCode == PICK_VIDEO) {
val selectedVideo = data.data
val filePathColumn = arrayOf(MediaStore.Video.Media.DATA)
val cursor = context!!.contentResolver.query(selectedVideo, filePathColumn, null, null, null)
cursor.moveToFirst()
val columnIndex = cursor.getColumnIndex(filePathColumn[0])
var path = cursor.getString(columnIndex)
cursor.close()
val intent = Intent(getMContext(), EditVideoActivity::class.java)
intent.putExtra(Constant.FILE_PATH, path)
startActivity(intent)
}
网友评论