piemonte / PBJVision

📸 iOS Media Capture – features touch-to-record video, slow motion, and photography
MIT License
1.93k stars 324 forks source link

Flash mode bugs fix #339

Closed felix8888 closed 7 years ago

felix8888 commented 7 years ago

Hey Sir, I found some bugs related to flash mode, so I fire this pull request to you, hope you can take a look it.

Thanks Felix

Kaspik commented 7 years ago

👍 - I made these changes and flash works on iOS 10+, very nice, approving this!

piemonte commented 7 years ago

thanks @felix8888 @Kaspik 🙌

Kaspik commented 7 years ago

@piemonte @felix8888 One more fix please (I don't wanna fork and include this one row fix).

PBJVision.m - row 1739, On iPhone 5, 6 etc with iOS 10 and front camera - it crashes if flashMode is not off (because these older devices don't support flash from screen).

please change whole row from:

settings.flashMode = (AVCaptureFlashMode)self.flashMode;

to

settings.flashMode = [self isFlashAvailable] ? (AVCaptureFlashMode)self.flashMode : AVCaptureFlashModeOff;

Also, method isFlashAvailable should have one more check:

return (_currentDevice && [_currentDevice hasFlash] && [_currentDevice isFlashAvailable]);

via apple doc: The value of this property is a BOOL indicating whether the receiver's flash is currently available. The flash may become unavailable if, for example, the device overheats and needs to cool off.

Kaspik commented 7 years ago

@piemonte The same fix applies to your NextLevel Swift camera project (FlashModeOn for front camera on older devices). :)