diff --git a/package/ios/CameraView+RecordVideo.swift b/package/ios/CameraView+RecordVideo.swift index 8ecad27..a9a4153 100644 --- a/package/ios/CameraView+RecordVideo.swift +++ b/package/ios/CameraView+RecordVideo.swift @@ -18,6 +18,13 @@ extension CameraView: AVCaptureVideoDataOutputSampleBufferDelegate, AVCaptureAud do { let options = try RecordVideoOptions(fromJSValue: options) + // If flash is on, just enable torch + if options.flash != .off { + cameraSession.configure { config in + config.torch = options.flash + } + } + // Start Recording with success and error callbacks cameraSession.startRecording( options: options, @@ -40,6 +47,11 @@ extension CameraView: AVCaptureVideoDataOutputSampleBufferDelegate, AVCaptureAud func stopRecording(promise: Promise) { cameraSession.stopRecording(promise: promise) + + // If flash was used, we had the torch enabled. Now set it back to it's original state. + cameraSession.configure { config in + config.torch = try Torch(jsValue: torch) + } } func pauseRecording(promise: Promise) { diff --git a/package/ios/CameraView.swift b/package/ios/CameraView.swift index 8198d2c..789acc0 100644 --- a/package/ios/CameraView.swift +++ b/package/ios/CameraView.swift @@ -214,7 +214,7 @@ public final class CameraView: UIView, CameraSessionDelegate { // Side-Props config.fps = fps?.int32Value config.enableLowLightBoost = lowLightBoost - config.torch = getTorch() + config.torch = try Torch(jsValue: torch) // Zoom config.zoom = zoom.doubleValue diff --git a/package/ios/Core/CameraSession+Video.swift b/package/ios/Core/CameraSession+Video.swift index 85ebf2f..39ce060 100644 --- a/package/ios/Core/CameraSession+Video.swift +++ b/package/ios/Core/CameraSession+Video.swift @@ -22,13 +22,6 @@ extension CameraSession { let start = DispatchTime.now() ReactLogger.log(level: .info, message: "Starting Video recording...") - if options.flash != .off { - // use the torch as the video's flash - self.configure { config in - config.torch = options.flash - } - } - // Get Video Output guard let videoOutput = self.videoOutput else { if self.configuration?.video == .disabled {