我创建了一个获取视频的函数
private val projectionVideo = arrayOf(
MediaStore.Video.Media._ID, //ID
MediaStore.Video.Media.DISPLAY_NAME, //NAME
MediaStore.Video.Media.DATA, //PATH TO CONTENT
MediaStore.Video.Media.DATE_TAKEN, //DATE
MediaStore.Video.Media.DURATION,
MediaStore.Video.Media.SIZE
)
private fun queryVideos(cr: ContentResolver): Cursor? =
cr.query(
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
projectionVideo, null, null,
MediaStore.Video.Media.DATE_TAKEN + " $SORT_ORDER"
)
Run Code Online (Sandbox Code Playgroud)
爪哇语
public static Uri getContentUri(String volumeName) {
return Uri.parse(CONTENT_AUTHORITY_SLASH + volumeName +
"/video/media");
}
/**
* The content:// style URI for the internal storage.
*/
public static final Uri INTERNAL_CONTENT_URI =
getContentUri("internal");
/**
* The content:// style URI for the "primary" external storage
* volume. …Run Code Online (Sandbox Code Playgroud)