Video files now must not be null

v2
Mattia Iavarone 6 years ago
parent 468c57cbe3
commit d5e1bb16f2
  1. 4
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/IntegrationTest.java
  2. 10
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java
  3. 3
      docs/_posts/2018-12-20-v1-migration-guide.md

@ -18,6 +18,7 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import java.io.File;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -149,7 +150,8 @@ public class IntegrationTest extends BaseTest {
private void waitForVideoStart() { private void waitForVideoStart() {
controller.mStartVideoTask.listen(); controller.mStartVideoTask.listen();
camera.takeVideo(null); File file = new File(context().getFilesDir(), "video.mp4");
camera.takeVideo(file);
controller.mStartVideoTask.await(400); controller.mStartVideoTask.await(400);
} }

@ -1284,10 +1284,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
* *
* @param file a file where the video will be saved * @param file a file where the video will be saved
*/ */
public void takeVideo(@Nullable File file) { public void takeVideo(@NonNull File file) {
if (file == null) {
file = new File(getContext().getFilesDir(), "video.mp4");
}
mCameraController.takeVideo(file); mCameraController.takeVideo(file);
mUiHandler.post(new Runnable() { mUiHandler.post(new Runnable() {
@Override @Override
@ -1307,11 +1304,8 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
* *
* @param file a file where the video will be saved * @param file a file where the video will be saved
*/ */
public void takeVideoSnapshot(@Nullable File file) { public void takeVideoSnapshot(@NonNull File file) {
if (getWidth() == 0 || getHeight() == 0) return; if (getWidth() == 0 || getHeight() == 0) return;
if (file == null) {
file = new File(getContext().getFilesDir(), "video.mp4");
}
mCameraController.takeVideoSnapshot(file, AspectRatio.of(getWidth(), getHeight())); mCameraController.takeVideoSnapshot(file, AspectRatio.of(getWidth(), getHeight()));
mUiHandler.post(new Runnable() { mUiHandler.post(new Runnable() {
@Override @Override

@ -117,6 +117,9 @@ Some new APIs were introduced, which are respected by both standard videos and s
- `setAudioBitRate()` and `cameraAudioBitRate`: sets the audio bit rate in bit/s - `setAudioBitRate()` and `cameraAudioBitRate`: sets the audio bit rate in bit/s
- `setVideoBitRate()` and `cameraVideoBitRate`: sets the video bit rate in bit/s - `setVideoBitRate()` and `cameraVideoBitRate`: sets the video bit rate in bit/s
**Important: takeVideo(), like takeVideoSnapshot(), will not accept a null file as input. Use
new File(context.getFilesDir(), "video.mp4") to use the old default.**
### Camera Preview ### Camera Preview
The type of preview is now configurable with `cameraPreview` XML attribute and `Preview` control class. The type of preview is now configurable with `cameraPreview` XML attribute and `Preview` control class.

Loading…
Cancel
Save