Chewie The Chorkie
Chewie The Chorkie

Reputation: 5234

How to check if AVCaptureSession preset resolution is supported in Swift

For instance, I may want to set it to hd1280x720, but only if it's supported, and use a lower res that is supported otherwise.

session = AVCaptureSession()
if(**my device supports hd1280x720**){
  session!.sessionPreset = AVCaptureSession.Preset.hd1280x720
}else if(**my device supports 640x480**){
  session!.sessionPreset = AVCaptureSession.Preset.vga640x480
}

Upvotes: 2

Views: 4906

Answers (1)

Martin R
Martin R

Reputation: 539765

Use AVCaptureSession.canSetSessionPreset(_:):

Returns a Boolean value that indicates whether the receiver can use the given preset.

Upvotes: 3

Related Questions