最近正好用到了调用系统摄像机实现录像还有限制时长大小的功能,找了找资料,并不难,只是大家可能用的不多,时间长有点忘了吧,记录一下,方便你、我、他、它嘛~嘿嘿
1.主要方法:
private fun video() {
try {
val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
val date = Date(System.currentTimeMillis())
var videoname = format.format(date)
videoFile = File(FileUtils.downpath, videoname + ".mp4")
if (videoFile!!.exists()) {
videoFile!!.delete()
}
videoFile!!.createNewFile()
val intent = Intent(MediaStore.ACTION_VIDEO_CAPTURE)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
intent.flags = Intent.FLAG_GRANT_WRITE_URI_PERMISSION
camera_URI = FileProvider.getUriForFile(context, Constent.Provider, videoFile!!)
} else {
camera_URI = Uri.fromFile(vid