SurfaceRecorder

class SurfaceRecorder(videoSettings: MiSnapSettings.Camera.VideoRecord, outputPath: String)

Deprecated

Use CameraView/MiSnapView recording capabilities instead

The SurfaceRecorder acts as an adapter between the Android camera and the SurfaceView that the preview will be displayed on. This allows it to record a video of the preview and save it to the file system.

Restarting video recording will overwrite the original video rather than appending to it.

Throws Exception if there was an error while instantiating.

NOTE: if using this class for low level video recording capabilities, it is necessary to customize the MiSnapSettings.Camera.VideoRecord to match the desired video resolution in the correct orientation by using the MiSnapSettings.Camera.VideoRecord.videoResolution property.

Constructors

Link copied to clipboard
constructor(videoSettings: MiSnapSettings.Camera.VideoRecord, outputPath: String)

Functions

Link copied to clipboard
fun bindSurfaceView(surfaceView: SurfaceView)

Binds the SurfaceRecorder to the provided SurfaceView, once bound and initialized the resulting SurfaceTexture will be posted to surfaceLiveData.

Link copied to clipboard
fun bindTextureView(textureView: TextureView)

Binds the SurfaceRecorder to the provided TextureView, once bound and initialized the resulting SurfaceTexture will be posted to surfaceLiveData.

Link copied to clipboard
fun resetSettings(videoSettings: MiSnapSettings.Camera.VideoRecord, outputPath: String)

Resets the video's settings and output path. If a video was already being recorded, it will be closed and recording will need to be started again.

Link copied to clipboard

Enables recording of the preview from the camera. If the preview has not yet started, then recording will begin as soon as it does.

Link copied to clipboard
fun stopRecording(writeFinishedCallback: () -> Unit = {})

Disables recording of the preview from the camera. The preview will continue to display to the user, but the video file will no longer be updated.

Link copied to clipboard

Releases the currently bound View. This is handled automatically when the Surface or SurfaceTexture is destroyed, and so the method only needs to be called if switching from one View to another. NOTE: Releasing the surface automatically stops recording video, and rebinding to a new View and then restarting video recording will overwrite the old video.

Properties

Link copied to clipboard
@get:JvmName(name = "isRecording")
var recording: Boolean
Link copied to clipboard

The fully initialized SurfaceTexture to be passed to the camera after a SurfaceView or TextureView have been bound.