fix storing videos on the SD card
This commit is contained in:
parent
740a1e4e20
commit
6f8b6c4b49
|
@ -23,22 +23,24 @@ fun Context.getOutputMediaFile(isPhoto: Boolean): String {
|
||||||
|
|
||||||
val timestamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date())
|
val timestamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date())
|
||||||
return if (isPhoto) {
|
return if (isPhoto) {
|
||||||
"${mediaStorageDir.path}${File.separator}IMG_$timestamp.jpg"
|
"${mediaStorageDir.path}/IMG_$timestamp.jpg"
|
||||||
} else {
|
} else {
|
||||||
"${mediaStorageDir.path}${File.separator}VID_$timestamp.mp4"
|
"${mediaStorageDir.path}/VID_$timestamp.mp4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val Context.usableScreenSize: Point get() {
|
val Context.usableScreenSize: Point
|
||||||
|
get() {
|
||||||
val size = Point()
|
val size = Point()
|
||||||
windowManager.defaultDisplay.getSize(size)
|
windowManager.defaultDisplay.getSize(size)
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
val Context.realScreenSize: Point get() {
|
val Context.realScreenSize: Point
|
||||||
|
get() {
|
||||||
val size = Point()
|
val size = Point()
|
||||||
windowManager.defaultDisplay.getRealSize(size)
|
windowManager.defaultDisplay.getRealSize(size)
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
val Context.navBarHeight: Int get() = realScreenSize.y - usableScreenSize.y
|
val Context.navBarHeight: Int get() = realScreenSize.y - usableScreenSize.y
|
||||||
|
|
|
@ -608,8 +608,9 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
||||||
|
|
||||||
// VIDEO RECORDING
|
// VIDEO RECORDING
|
||||||
fun initRecorder(): Boolean {
|
fun initRecorder(): Boolean {
|
||||||
if (mCamera == null || mRecorder != null || !mIsSurfaceCreated)
|
if (mCamera == null || mRecorder != null || !mIsSurfaceCreated) {
|
||||||
return false
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
refreshPreview()
|
refreshPreview()
|
||||||
mSwitchToVideoAsap = false
|
mSwitchToVideoAsap = false
|
||||||
|
@ -680,7 +681,7 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var document = mActivity!!.getDocumentFile(mCurrVideoPath)
|
var document = mActivity!!.getDocumentFile(mCurrVideoPath.getParentPath())
|
||||||
if (document == null) {
|
if (document == null) {
|
||||||
mActivity!!.toast(R.string.unknown_error_occurred)
|
mActivity!!.toast(R.string.unknown_error_occurred)
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue