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:
@@ -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) {
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user