Video files now must not be null

pull/360/head
Mattia Iavarone 6 years ago
parent d7a593e070
commit e9df75b7ae
  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.runner.RunWith;
import java.io.File;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@ -149,7 +150,8 @@ public class IntegrationTest extends BaseTest {
private void waitForVideoStart() {
controller.mStartVideoTask.listen();
camera.takeVideo(null);
File file = new File(context().getFilesDir(), "video.mp4");
camera.takeVideo(file);
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
*/
public void takeVideo(@Nullable File file) {
if (file == null) {
file = new File(getContext().getFilesDir(), "video.mp4");
}
public void takeVideo(@NonNull File file) {
mCameraController.takeVideo(file);
mUiHandler.post(new Runnable() {
@Override
@ -1307,11 +1304,8 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
*
* @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 (file == null) {
file = new File(getContext().getFilesDir(), "video.mp4");
}
mCameraController.takeVideoSnapshot(file, AspectRatio.of(getWidth(), getHeight()));
mUiHandler.post(new Runnable() {
@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
- `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
The type of preview is now configurable with `cameraPreview` XML attribute and `Preview` control class.

Loading…
Cancel
Save