feat: Add pauseRecording and resumeRecording 🔥 (#911)

* feat: Add `pauseRecording` and `resumeRecording` (iOS)

* feat: Add `pauseRecording` and `resumeRecording` (Android)

* feat: Add `pauseRecording` and `resumeRecording` (JS)

* fix: Simplify Swift code for Recording
This commit is contained in:
Marc Rousavy
2022-03-22 10:44:58 +01:00
committed by GitHub
parent eb95add5ce
commit 4b9bcb37e0
6 changed files with 121 additions and 10 deletions

View File

@@ -82,6 +82,30 @@ fun CameraView.startRecording(options: ReadableMap, onRecordCallback: Callback)
})
}
@SuppressLint("RestrictedApi")
fun CameraView.pauseRecording() {
if (videoCapture == null) {
throw CameraNotReadyError()
}
if (activeVideoRecording == null) {
throw NoRecordingInProgressError()
}
activeVideoRecording!!.pause()
}
@SuppressLint("RestrictedApi")
fun CameraView.resumeRecording() {
if (videoCapture == null) {
throw CameraNotReadyError()
}
if (activeVideoRecording == null) {
throw NoRecordingInProgressError()
}
activeVideoRecording!!.resume()
}
@SuppressLint("RestrictedApi")
fun CameraView.stopRecording() {
if (videoCapture == null) {

View File

@@ -115,6 +115,24 @@ class CameraViewModule(reactContext: ReactApplicationContext) : ReactContextBase
}
}
@ReactMethod
fun pauseRecording(viewTag: Int, promise: Promise) {
withPromise(promise) {
val view = findCameraView(viewTag)
view.pauseRecording()
return@withPromise null
}
}
@ReactMethod
fun resumeRecording(viewTag: Int, promise: Promise) {
withPromise(promise) {
val view = findCameraView(viewTag)
view.resumeRecording()
return@withPromise null
}
}
@ReactMethod
fun stopRecording(viewTag: Int, promise: Promise) {
withPromise(promise) {