getCameraDevice

function getCameraDevice(
   devices: CameraDevice[], 
   position: CameraPosition, 
   filter?: DeviceFilter): CameraDevice | undefined

Get the best matching Camera device that best satisfies your requirements using a sorting filter, or undefined if not Cameras are available on this platform.

If this platform has any Cameras at the given position, this method will always return a Camera device, so filter never excludes cameras.

Parameters

position

The position of the Camera device relative to the phone.

filter

The filter you want to use. The Camera device that matches your filter the closest will be returned

Returns

The Camera device that matches your filter the closest, or undefined if no Camera Device exists on this platform.

Example

const device = getCameraDevice(devices, 'back', {
   physicalDevices: ['wide-angle']
})