This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val recordingListener = Consumer<VideoRecordEvent> { event -> | |
when(event) { | |
is VideoRecordEvent.Start -> { | |
val msg = “Capture Started” | |
Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT) | |
.show() | |
// update app internal recording state | |
… | |
} | |
is VideoRecordEvent.Finalize -> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val contentValues = ContentValues().apply { | |
put(MediaStore.MediaColumns.DISPLAY_NAME, “CameraX-VideoCapture”) | |
put(MediaStore.MediaColumns.MIME_TYPE, "video/mp4") | |
} | |
val mediaStoreOutputOptions = MediaStoreOutputOptions | |
.Builder(contentResolver, MediaStore.Video.Media.EXTERNAL_CONTENT_URI) | |
.setContentValues(contentValues) | |
.build() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(event == VideoRecordEvent.Finalize) { | |
if (!event.hasError()) { | |
val playback = Intent(Intent.ACTION_VIEW).apply { | |
setDataAndType(event.outputResults.outputUri, "video/*") | |
} | |
startActivity(playback); | |
} else { | |
// update app state when the capture failed. | |
recording?.close() | |
recording = null |
OlderNewer