Skip to content

Commit

Permalink
消除未指定videoCapture类型的警告
Browse files Browse the repository at this point in the history
  • Loading branch information
heat committed Mar 20, 2022
1 parent 02801e9 commit f2062b5
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions app/src/main/java/com/awo/newcameraxtest/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@
import androidx.camera.video.Recording;
import androidx.camera.video.VideoCapture;
import androidx.camera.video.VideoRecordEvent;
import androidx.camera.view.PreviewView;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import com.awo.newcameraxtest.databinding.ActivityMainBinding;
import com.google.common.util.concurrent.ListenableFuture;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.Objects;
Expand All @@ -46,7 +44,7 @@ public class MainActivity extends AppCompatActivity {

private ImageCapture imageCapture = null;

private VideoCapture videoCapture = null;
private VideoCapture<Recorder> videoCapture = null;
private Recording recording = null;

private ExecutorService cameraExecutor;
Expand Down Expand Up @@ -109,8 +107,7 @@ private void captureVideo() {
new String[]{Manifest.permission.RECORD_AUDIO},
Configuration.REQUEST_CODE_PERMISSIONS);
}
Recorder recorder = (Recorder) videoCapture.getOutput();
recording = recorder.prepareRecording(this, mediaStoreOutputOptions)
recording = videoCapture.getOutput().prepareRecording(this, mediaStoreOutputOptions)
.withAudioEnabled() // 开启音频录制
.start(ContextCompat.getMainExecutor(this), videoRecordEvent -> {
if (videoRecordEvent instanceof VideoRecordEvent.Start) {
Expand Down Expand Up @@ -188,7 +185,6 @@ private void startCamera() {
ProcessCameraProvider processCameraProvider = cameraProviderFuture.get();

// 创建一个Preview 实例,并设置该实例的 surface 提供者(provider)。
PreviewView viewFinder = (PreviewView)findViewById(R.id.viewFinder);
Preview preview = new Preview.Builder()
.build();
preview.setSurfaceProvider(viewBinding.viewFinder.getSurfaceProvider());
Expand Down Expand Up @@ -260,12 +256,6 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
}
}

private File getOutputDirectory() {
File mediaDir = new File(getExternalMediaDirs()[0], getString(R.string.app_name));
boolean isExist = mediaDir.exists() || mediaDir.mkdir();
return isExist ? mediaDir : null;
}

@Override
protected void onDestroy() {
super.onDestroy();
Expand Down

0 comments on commit f2062b5

Please sign in to comment.