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

pull/360/head
Mattia Iavarone 6 years ago
parent d291d88814
commit 2760b64953
  1. 10
      cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java

@ -1,5 +1,6 @@
package com.otaliastudios.cameraview; package com.otaliastudios.cameraview;
import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.graphics.ImageFormat; import android.graphics.ImageFormat;
import android.graphics.PointF; import android.graphics.PointF;
@ -11,6 +12,7 @@ import android.location.Location;
import android.os.Build; import android.os.Build;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.annotation.WorkerThread; import android.support.annotation.WorkerThread;
import android.support.media.ExifInterface; import android.support.media.ExifInterface;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
@ -696,9 +698,15 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera
}); });
} }
@SuppressLint("NewApi")
@Override @Override
void takeVideoSnapshot(@NonNull final File file) { 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() { schedule(mStartVideoTask, true, new Runnable() {
@Override @Override
public void run() { public void run() {

Loading…
Cancel
Save