Skip to content

Commit

Permalink
remove unused codes and set recording null after recording
Browse files Browse the repository at this point in the history
  • Loading branch information
YushraJewon committed May 30, 2024
1 parent 029c815 commit 041a975
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/android/CameraPreviewFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,18 +280,17 @@ public void hasFlash(HasFlashCallback hasFlashCallback) {
public void captureVideo(VideoCallback videoCallback) {
if (recording != null) {
recording.stop();
recording = null;
return;
}
UUID uuid = UUID.randomUUID();

String filename = uuid.toString() + ".mp4";
ContentValues contentValues = new ContentValues();
contentValues.put(MediaStore.Video.Media.DISPLAY_NAME, filename);
if (ActivityCompat.checkSelfPermission(this.getContext(), Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this.getActivity(), new String[]{Manifest.permission.RECORD_AUDIO}, 200);
}
File videoFile = new File(
getContext().getApplicationContext().getFilesDir(),
getContext().getFilesDir(),
filename
);

Expand All @@ -315,8 +314,8 @@ public void captureVideo(VideoCallback videoCallback) {
videoCallback.onStop(false, Uri.fromFile(videoFile).toString());
Uri savedUri = finalizeEvent.getOutputResults().getOutputUri();
Log.i(TAG, "Video saved to: " + savedUri);
recording = null;
}
recording = null;
}
// Other event types can be handled if needed
});
Expand Down

0 comments on commit 041a975

Please sign in to comment.