2

Is there a way to specify to the device that when one sets setTorchModeOnWithLevel that they would activate the Retina Flash (iPhone6s/7's front facing flash) instead of the back True-Tone LED Flash?

The following standard code appears to only be able to activate the rear LED:

AVCaptureDevice.defaultDevice(withDeviceType: AVCaptureDeviceType.builtInDualCamera,
     mediaType: AVMediaTypeVideo, position: .front)
try device.lockForConfiguration();
let torchOn = !device.isTorchActive;
try device.setTorchModeOnWithLevel(1.0);
device.unlockForConfiguration();

Does an API exist within iOS for one to have access to the Retina Flash?

Jake Chasan
  • 6,290
  • 9
  • 44
  • 90
  • Is your capture device the front camera? (AVCaptureDevicePosition.front) – Emptyless Jan 22 '17 at 17:58
  • @Emptyless: Yes, I am using the constructor where I pass in "position: .front" (updated question with the constructor). Any ideas as to why it may not be showing? Thanks. – Jake Chasan Jan 22 '17 at 18:49
  • `AVCaptureDevice` also has a bunch of properties for `flash` (separate from `torch`). Have you tried those? More info: https://developer.apple.com/reference/avfoundation/avcapturedevice/1388116-flashmode – Dave Weston Jan 23 '17 at 00:25
  • @DaveWeston It seems like the flash properties are deprecated, any other suggestions? – Jake Chasan Jan 23 '17 at 00:49
  • It looks like the flash settings have moved to `AVCapturePhotoSettings` as of iOS 10. Reference for this class is: https://developer.apple.com/reference/avfoundation/avcapturephotosettings – Dave Weston Jan 23 '17 at 01:01
  • This video from WWDC 2016 might help: https://developer.apple.com/videos/play/wwdc2016/501/ – Dave Weston Jan 23 '17 at 01:05

1 Answers1

4

AFAIK iOS DON'T have any API specific to Retina Flash. (as of dated iOS 10.2)

From Apple developer thread

Retina Flash iPhone 6s and 6s Plus contain a custom display chip that allows the retina display to briefly flash 3 times brighter than its usual maximum illuminance. No new API was added to support this feature. Since iOS 4, AVCaptureDevice has supported the -hasFlash, -isFlashModeSupported: and -flashMode properties. The iPhone 6s and 6s Plus front-facing cameras are the first front-facing iOS cameras to respond YES to the -hasFlash property. By setting the front-facing camera's flashMode to AVCaptureFlashModeOn or AVCaptureFlashModeAuto, the retina flash fires when a still image is captured (see AVCaptureStillImageOutput’s captureStillImageAsynchronouslyFromConnection:completionHandler:), just as the True Tone flash fires for rear-facing camera stills.

So to make your code to work check -hasFlash and then set the Flash mode to auto or on.

Bluewings
  • 3,438
  • 3
  • 18
  • 31
  • Is there any way to perform a Retina Flash without taking a picture, or is that a necessity? – Jake Chasan Jan 23 '17 at 04:55
  • @JakeChasan we cannot trigger retina flash without taking picture. I have been trying to get that as well. but from apple documentation there is no options. – Bluewings Jan 23 '17 at 04:57