Skip to content

Commit

Permalink
setQuality lowest and remove toast
Browse files Browse the repository at this point in the history
  • Loading branch information
YushraJewon committed Apr 3, 2024
1 parent 3aa4f2f commit ddcce21
Showing 1 changed file with 1 addition and 40 deletions.
41 changes: 1 addition & 40 deletions src/android/CameraPreviewFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -126,38 +125,6 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
}


// public void startCamera() {
// ListenableFuture<ProcessCameraProvider> cameraProviderFuture = ProcessCameraProvider.getInstance(getActivity());
// cameraProviderFuture.addListener(() -> {
// try {
// // Used to bind the lifecycle of cameras to the lifecycle owner
// ProcessCameraProvider cameraProvider = cameraProviderFuture.get();
//
// Recorder recorder = new Recorder.Builder()
// .setQualitySelector(QualitySelector.from(Quality.HIGHEST))
// .build();
// videoCapture = VideoCapture.withOutput(recorder);
// imageCapture = new ImageCapture.Builder().build();
//
// // Select back camera as a default
// CameraSelector cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA;
// try {
// // Unbind use cases before rebinding
// cameraProvider.unbindAll();
// // Bind use cases to camera
// cameraProvider.bindToLifecycle(
// this, cameraSelector, preview, imageCapture, videoCapture);
// } catch (Exception exc) {
// Log.e(TAG, "Use case binding failed", exc);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }, ContextCompat.getMainExecutor(this.getContext()));
// if (startCameraCallback != null) {
// startCameraCallback.onCameraStarted(null);
// }
// }
public void startCamera() {
ListenableFuture<ProcessCameraProvider> cameraProviderFuture = ProcessCameraProvider.getInstance(getActivity());

Expand All @@ -180,7 +147,7 @@ public void startCamera() {
}

Recorder recorder = new Recorder.Builder()
.setQualitySelector(QualitySelector.from(Quality.HD))
.setQualitySelector(QualitySelector.from(Quality.LOWEST))
.build();
videoCapture = VideoCapture.withOutput(recorder);

Expand Down Expand Up @@ -304,8 +271,6 @@ public void captureVideo(boolean useFlash, VideoCallback videoCallback) {
camera.getCameraControl().enableTorch(useFlash);
}
if (recording != null) {
Toast.makeText(this.getContext(), "Video not null" , Toast.LENGTH_LONG).show();

recording.stop();
return;
}
Expand All @@ -332,10 +297,7 @@ public void captureVideo(boolean useFlash, VideoCallback videoCallback) {
.start(ContextCompat.getMainExecutor(this.getContext()), videoRecordEvent -> {
if (videoRecordEvent instanceof VideoRecordEvent.Start) {
videoCallback.onStart(null,true, null);
Toast.makeText(this.getContext(), "Video start" , Toast.LENGTH_LONG).show();

} else if (videoRecordEvent instanceof VideoRecordEvent.Finalize) {
Toast.makeText(this.getContext(), "Video fin" , Toast.LENGTH_LONG).show();
VideoRecordEvent.Finalize finalizeEvent = (VideoRecordEvent.Finalize) videoRecordEvent;
if (finalizeEvent.hasError()) {
// Handle the error
Expand All @@ -347,7 +309,6 @@ public void captureVideo(boolean useFlash, VideoCallback videoCallback) {
videoCallback.onStop(null, false, Uri.fromFile(videoFile).toString());
Uri savedUri = finalizeEvent.getOutputResults().getOutputUri();
Log.d(TAG, "Video saved to: " + savedUri);
Toast.makeText(this.getContext(), "Video stop" + savedUri, Toast.LENGTH_LONG).show();
recording = null;
}
}
Expand Down

0 comments on commit ddcce21

Please sign in to comment.