Application crashing while accessing microphone in iOS 12.1.2 for iPhone XS

849 Views Asked by At

I am working on iOS application which uses microphone for video capture. When we try to capture video, it asks for microphone permission and crashes immediately after that. We are getting following error:

"Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: -[AVCaptureDevice setActiveColorSpace:] Not supported - use activeFormat.supportedColorSpaces"

We have tried searching for this property for AVCaptureDevice. However, not able to find the same.

1

There are 1 best solutions below

0
On

We have tried searching for this property for AVCaptureDevice. However, not able to find the same.

Solution:

The property SupportedColorSpaces really exist under AVCaptureDevice.ActiveFormat, make sure you get the correct instance of AVCaptureDevice:

To use it, for example:

 var videoDevs = AVCaptureDevice.DevicesWithMediaType(AVMediaType.Video);
 var device = videoDevs[0];
 NSNumber[] arr = device.ActiveFormat.SupportedColorSpaces;

Document is here:

AVCaptureDeviceFormat

AVFoundation.AVCaptureDevice

SupportedColorSpaces