0

Here's the code I'm working with:

func toggleflash(On on: Bool){
        guard let session = captureSession where session.running == true else {
            return
        }
        session.beginConfiguration()
        let input = session.inputs[0] as! AVCaptureDeviceInput

            if input.device.isFlashModeSupported(.On) {
                do {
                    try input.device.lockForConfiguration()
                    input.device.flashMode = .On
                    input.device.unlockForConfiguration()
                }catch {}

            }

        session.commitConfiguration()
    }

When I use this function to use flash on my front camera, the iPhone screen does everything you'd expect. It flashes, but it doesn't illuminate the subject the way that the iPhone camera app/snapchat/instagram does. So I wonder if it's not bright enough or if it's not working correctly.

  • Looks like AVCaptureDeviceInput flashMode is depreciated. Have you had a look at AVCapturePhotoFlashMode? How to use here: http://stackoverflow.com/questions/3204008/how-do-i-use-avcaptureflashmode Documentation here: https://developer.apple.com/reference/avfoundation/avcapturephotosettings/1648760-flashmode – Si-N Aug 24 '16 at 13:39
  • @Si-N I can't find where it says flashMode is depreciated. https://developer.apple.com/reference/avfoundation/avcapturedevice says something else is depreciated. And the link you sent me says that "this setting supercedes..." –  Aug 24 '16 at 14:34

0 Answers0