Skip to content

Instantly share code, notes, and snippets.

@mayowa-egbewunmi
Last active July 31, 2022 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mayowa-egbewunmi/b0526de5e8ac2236a672bbd625fdc0cd to your computer and use it in GitHub Desktop.
Save mayowa-egbewunmi/b0526de5e8ac2236a672bbd625fdc0cd to your computer and use it in GitHub Desktop.
@Composable
internal fun RecordingScreen(viewModel: RecordingViewModel) {
...
val listener = remember(viewModel) {
object : VideoCaptureManager.Listener {
...
override fun recordingPaused() {
//Dispatch Recording Paused Event to the viewModel
}
override fun onProgress(progress: Int) {
//Dispatch Recording Progress Event to the viewModel
}
override fun recordingCompleted(outputUri: Uri) {
//Dispatch Recording Completed Event to the viewModel
}
override fun onError(throwable: Throwable?) {
//Dispatch Recording Error Event to the viewModel
}
}
}
LaunchedEffect(viewModel) {
viewModel.effect.collect {
when (it) {
is RecordingViewModel.Effect.RecordVideo -> captureManager.startRecording(it.filePath)
RecordingViewModel.Effect.PauseRecording -> captureManager.pauseRecording()
RecordingViewModel.Effect.ResumeRecording -> captureManager.resumeRecording()
RecordingViewModel.Effect.StopRecording -> captureManager.stopRecording()
}
}
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment