Last active
July 31, 2022 20:39
-
-
Save mayowa-egbewunmi/b0526de5e8ac2236a672bbd625fdc0cd to your computer and use it in GitHub Desktop.
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
@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