CameraEngine icon indicating copy to clipboard operation
CameraEngine copied to clipboard

Error permisions of Microphone

Open davidlondono opened this issue 9 years ago • 7 comments

i got this fatal error ´´´Swift fatalError("[CameraEngine] error initInputDevice") ´´´

And i print put the error, it was this one: Error Domain=AVFoundationErrorDomain Code=-11852 "Cannot use iPod Microphone" UserInfo={NSLocalizedDescription=Cannot use iPod Microphone, AVErrorDeviceKey=<AVCaptureFigAudioDevice: 0x14f66450 [iPod Microphone][com.apple.avfoundation.avcapturedevice.built-in_audio:0]>, NSLocalizedFailureReason=This app is not authorized to use iPod Microphone.}

I know I have tuned off the microphone permissions, but this error should not occur if I will only use the camera without video.

for testing I will turn on the microphone, but I should be able to take photos without this permission

davidlondono avatar May 03 '16 14:05 davidlondono

Permission error ! Thanks for reporting again, your contribution is awesome thanks again. I will check it out.

remirobert avatar May 04 '16 00:05 remirobert

you could add also the permisions promp like a function .askCameraPermision(callback) .askCameraPermision(callback)

also variables to know if it has pemission of the AVFoundation, check the library CameraManager for some inspiration 😄

davidlondono avatar May 04 '16 14:05 davidlondono

@davidlondono Thanks I am currently working on it. I will provide a fix soon. Thanks again for your help. It makes CameraEngine so much better !

remirobert avatar May 05 '16 00:05 remirobert

@davidlondono how did you fix the error? It still occurs for me when user cancels permission for mic or camera. Which would have been fine except that the error occurs when I initialize camera engine let cameraEngine = CameraEngine() which means before I get the chance to ask for permission again, the fatal error will occur. This is bad when your initial view controller is displaying a camera.

otymartin avatar Aug 21 '16 15:08 otymartin

just check if camera is available manually with UIKit and then if it is available create the CameraEngine instance

davidlondono avatar Aug 22 '16 14:08 davidlondono

@davidlondono That means I can't have a global instance of cameraEngine declared. I would have to initialize it in every function I create that manipulates cameraEngine - Unless I'm wrong and there is a way I can do this at the top of my class?

if AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo) ==  AVAuthorizationStatus.Authorized
{
    let cameraEngine = CameraEngine()
}

otymartin avatar Aug 22 '16 14:08 otymartin

or create a class with a static function and static variable of CameraEngine, on the function return an optional CameraEngine and return nil if is not authorized

davidlondono avatar Aug 22 '16 14:08 davidlondono