new startCapturingVideo(File, long) for max duration

pull/1/head
Mattia Iavarone 7 years ago
parent 84c7f63443
commit 61c7b68e1e
  1. 3
      README.md
  2. 28
      camerakit/src/main/java/com/flurgle/camerakit/CameraView.java
  3. 2
      demo/src/main/res/layout/activity_main.xml

@ -145,6 +145,9 @@ camera.postDelayed(new Runnable() {
camera.stopRecordingVideo(); camera.stopRecordingVideo();
} }
}, 2500); }, 2500);
// Shorthand:
camera.startRecordingVideo(file, 2500);
``` ```
### Other camera events ### Other camera events

@ -859,6 +859,34 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
} }
/**
* Starts recording a video with selected options. Video will be written to the given file,
* so callers should ensure they have appropriate permissions to write to the file.
* Recording will be automatically stopped after durationMillis, unless
* {@link #stopCapturingVideo()} is not called meanwhile.
*
* @param file a file where the video will be saved
* @param durationMillis video max duration
*
* @throws IllegalArgumentException if durationMillis is < 500 milliseconds
*/
public void startCapturingVideo(File file, long durationMillis) {
if (durationMillis < 500) {
throw new IllegalArgumentException("Video duration can't be < 500 milliseconds");
}
startCapturingVideo(file);
postDelayed(new Runnable() {
@Override
public void run() {
stopCapturingVideo();
}
}, durationMillis);
}
// TODO: pauseCapturingVideo and resumeCapturingVideo. There is mediarecorder.pause(), but API 24...
/** /**
* Stops capturing video, if there was a video record going on. * Stops capturing video, if there was a video record going on.
* This will fire {@link CameraListener#onVideoTaken(File)}. * This will fire {@link CameraListener#onVideoTaken(File)}.

@ -23,7 +23,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="400dp" android:layout_height="400dp"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:adjustViewBounds="true" android:keepScreenOn="true"
app:cameraCropOutput="false" app:cameraCropOutput="false"
app:cameraFacing="back" app:cameraFacing="back"
app:cameraFlash="off" app:cameraFlash="off"

Loading…
Cancel
Save