Skip to content

Commit

Permalink
Enhance startRecording function to handle edge cases
Browse files Browse the repository at this point in the history
where there could be multiple calls to the function
  • Loading branch information
MHShetty authored and thestinger committed Feb 18, 2025
1 parent 64f9f1a commit ab4a919
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ class VideoCapturer(private val mActivity: MainActivity) {
fun startRecording() {
if (camConfig.camera == null) return
val recorder = camConfig.videoCapture?.output ?: return
if (isRecording) return
isRecording = true

val dateString = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(Date())
val fileName = VIDEO_NAME_PREFIX + dateString + videoFileFormat
Expand All @@ -163,6 +165,7 @@ class VideoCapturer(private val mActivity: MainActivity) {
includeAudio = true
} else {
ctx.restartRecordingWithMicPermission()
isRecording = false
return
}
}
Expand All @@ -175,6 +178,7 @@ class VideoCapturer(private val mActivity: MainActivity) {
camConfig.onStorageLocationNotFound()
}
ctx.showMessage(R.string.unable_to_access_output_file)
isRecording = false
return
}

Expand All @@ -186,8 +190,6 @@ class VideoCapturer(private val mActivity: MainActivity) {

beforeRecordingStarts()

isRecording = true

camConfig.mPlayer.playVRStartSound(handler) {

recording = pendingRecording.start(ctx.mainExecutor) { event ->
Expand Down

0 comments on commit ab4a919

Please sign in to comment.