MediaRecorder

An object that writes media data to a file.

Usages.

AndroidManifest.xml

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Code

var mixer = MediaMixer(context)
var recorder = [MediaRecorder](context)
mixer.registerOutput(recorder)
if (recorder.isRecording) {
recorder.stopRecording()
} else {
recorder.startRecording(
File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "output.mp4").toString(),
MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4
)
}

Constructors

Link copied to clipboard
constructor(context: Context)

Properties

Link copied to clipboard

Specifies the audio codec settings.

Link copied to clipboard

The source of the media data object.

Link copied to clipboard

The isRecording value indicates whether the audio recorder is recording.

Link copied to clipboard

Specifies the video codec settings.

Functions

Link copied to clipboard
open override fun append(buffer: MediaBuffer)

Invoked immediately after capture data.

Link copied to clipboard
@RequiresApi(value = 26)
fun startRecording(fd: FileDescriptor, format: Int)
fun startRecording(path: String, format: Int)

Starts recording.

Link copied to clipboard

Stops recording.