@Throws(IOException::class)
private fun createVideoFile(): File {
// Create an image file name
val timeStamp: String = SimpleDateFormat("yyyyMMdd_HHmmss").format(Date())
val storageDir: File? = getExternalFilesDir(Environment.DIRECTORY_MOVIES)
return File.createTempFile(
"oogoo_${timeStamp}_",
".mp4",
storageDir
).apply {
videoPath = this.path
videoUri = this.toUri()
}
}
Iam using CameraView to record Video . when stop record I get path of record
D/VideoTaken: /storage/emulated/0/Android/data/com.example.testgogoapplication/files/Movies/oogoo_20211021_125639_3062139219833544197.mp4
file:///storage/emulated/0/Android/data/com.example.testgogoapplication/files/Movies/oogoo_20211021_125639_3062139219833544197.mp4
put not found this path in Device how can access to this path?.
if there is another way to save the video to storage (best way to write file) by Kotlin
Use this:
This code inserts a video uri to
MediaStore, retrieves its file path, and removes it fromMediaStore. This path will be to the Movies directory which is public and does not require permissions. Now you can use this file path to create aFileobject like so:val file = File(createVideoOutputPath(context))