Throw if api level or preview do not support the video snapshot feature

v2
Mattia Iavarone 6 years ago
parent 818a57e94c
commit 26ac11cdc5
  1. 10
      cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java

@ -1,5 +1,6 @@
package com.otaliastudios.cameraview;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.graphics.ImageFormat;
import android.graphics.PointF;
@ -11,6 +12,7 @@ import android.location.Location;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.annotation.WorkerThread;
import android.support.media.ExifInterface;
import android.view.SurfaceHolder;
@ -696,9 +698,15 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera
});
}
@SuppressLint("NewApi")
@Override
void takeVideoSnapshot(@NonNull final File file) {
// TODO check api level and Preview instance
if (!(mPreview instanceof GLCameraPreview)) {
throw new IllegalStateException("Video snapshots are only supported with GLCameraPreview.");
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
throw new IllegalStateException("Video snapshots are only supported starting from API 18.");
}
schedule(mStartVideoTask, true, new Runnable() {
@Override
public void run() {

Loading…
Cancel
Save