Closed cswagner closed 3 years ago
Hi @cswagner,
When do you call RescueCamera.sharedInstance.enable(withAudio: <boolvalue>)
? RescueCamera.sharedInstance.hasFlash
returns false and RescueCamera.sharedInstance.flashState
returns unavailable until you call this method. It may be useful if you see our example application here: https://github.com/LogmeinRescue/iOS-SDK/tree/master/Examples/RescueCameraExample
You can get flashlight state changes via RescueCameraDelegate
(func rescueCameraFlashTurnedOn()
, func rescueCameraFlashTurnedOff()
). These delegate methods are invoked when the torchMode
property of the capture device changes. (RescueCamera.sharedInstance.flashState
is also based on capture device’s torchMode
.)
Daniel
Thanks for sharing the example application, @exceptioncatcher91!
Like the example, we are calling RescueCamera.sharedInstance.enable(withAudio: <boolvalue>)
in viewDidLoad
, well before we show the button to toggle flash on/off. Right after calling that method, we still see RescueCamera.sharedInstance.hasFlash
returning false
.
Rather than observing whether or not flash is turned on/off, is there a way to observe flash availability in general?
I looked into this problem a little bit deeper. Calling RescueCamera.sharedInstance.enable(withAudio: <boolvalue>)
is not enough to get valid value via RescueCamera.sharedInstance.hasFlash
, because value hasFlash
is based on the avCaptureDevice's hasTorch
property. When you would like to get the value of the hasFlash
property, the avCaptureDevice
is nil. Currently, there is no opportunity to observe that property. I need more time to decide how can i solve this problem for you, but is it going to be okay, if you get valid value immediately after you call RescueCamera.sharedInstance.enable(withAudio: <boolvalue>)
? I think, if i can solve this problem in this way, then you do not need to observe hasFlash
. Could you confirm this, please?
We've removed polling the value of hasFlash
and are, instead, checking it when streaming starts (via RescueCameraDelegate#rescueCameraStreamingStarted
. This is sufficient for our use case.
Would it be possible to add handling flashlight availability to the example app? That might help shine light on any necessary API changes.
Yes, its a good solution to check flashlight availability in RescueCameraDelegate#rescueCameraStreamingStarted
. We extend our example application with flashlight handling. Thanks your remark!
At the beginning of a camera streaming session, the value for
RescueCamera.sharedInstance.hasFlash
isfalse
and the value forRescueCamera.sharedInstance.flashState
is.unavailable
. Shortly after the session starts, these values switch totrue
and.off
, respectively. However, for the correspondingAVCaptureDevice
, it appears the torch is present and available from the beginning of the session (hasTorch
andisTorchAvailable
are bothtrue
).What criteria are used to determine flashlight availability and what is the best practice for observing changes in its value?
Our current strategy is to poll
RescueCamera.sharedInstance.hasFlash
periodically. Is it possible to observe changes through key-value observation instead?