feat: Add onStarted and onStopped events (#2273)

* feat: Add `onStarted` and `onStopped` events

* Implement `onStart` for Android

* Update CameraSession.kt

* Update CameraSessionDelegate.swift
This commit is contained in:
Marc Rousavy
2023-12-09 21:09:55 +03:00
committed by GitHub
parent 9ef4a9a210
commit 4ee52d6211
12 changed files with 105 additions and 11 deletions

View File

@@ -59,6 +59,8 @@ public final class CameraView: UIView, CameraSessionDelegate {
// events
@objc var onInitialized: RCTDirectEventBlock?
@objc var onError: RCTDirectEventBlock?
@objc var onStarted: RCTDirectEventBlock?
@objc var onStopped: RCTDirectEventBlock?
@objc var onViewReady: RCTDirectEventBlock?
@objc var onCodeScanned: RCTDirectEventBlock?
// zoom
@@ -283,7 +285,23 @@ public final class CameraView: UIView, CameraSessionDelegate {
guard let onInitialized = onInitialized else {
return
}
onInitialized([String: Any]())
onInitialized([:])
}
func onCameraStarted() {
ReactLogger.log(level: .info, message: "Camera started!")
guard let onStarted = onStarted else {
return
}
onStarted([:])
}
func onCameraStopped() {
ReactLogger.log(level: .info, message: "Camera stopped!")
guard let onStopped = onStopped else {
return
}
onStopped([:])
}
func onFrame(sampleBuffer: CMSampleBuffer) {