setDynamicAspectRatio(_:completionHandler:)
Updates the dynamic aspect ratio of the device.
Declaration
func setDynamicAspectRatio(_ dynamicAspectRatio: AVCaptureDevice.AspectRatio, completionHandler handler: (@Sendable (CMTime, (any Error)?) -> Void)? = nil)func setDynamicAspectRatio(_ dynamicAspectRatio: AVCaptureDevice.AspectRatio) async throws -> CMTimeParameters
- dynamicAspectRatio:
The new Aspectratio the device should output.
- handler:
A block called by the device when
dynamicAspectRatiois set to the value specified. If you call Setdynamicaspectratio(_:completionhandler:) multiple times, the completion handlers are called in FIFO order. The block receives a timestamp which matches that of the first buffer to which all settings have been applied. Note that the timestamp is synchronized to the device clock, and thus must be converted to the Synchronizationclock prior to comparison with the timestamps of buffers delivered via an Avcapturevideodataoutput. You may passnilfor thehandlerparameter if you do not need to know when the operation completes.
Discussion
This is the only way of setting dynamicAspectRatio. This method throws an NSInvalidArgumentException if dynamicAspectRatio is not a supported aspect ratio found in the device’s activeFormat’s supportedDynamicAspectRatios. This method throws an NSGenericException if you call it without first obtaining exclusive access to the device using lockForConfiguration().