openCamera method

Future<MediaStream> openCamera({
  1. MediaDevice? device,
  2. bool? facingMode,
})

Implementation

Future<rtc.MediaStream> openCamera(
    {MediaDevice? device, bool? facingMode}) async {
  var constraints = <String, dynamic>{
    if (facingMode != null) 'facingMode': facingMode ? 'user' : 'environment',
  };
  if (device != null) {
    if (lkPlatformIs(PlatformType.web)) {
      constraints['deviceId'] = device.deviceId;
    } else {
      constraints['optional'] = [
        {'sourceId': device.deviceId}
      ];
    }
  }
  selectedVideoInput = device;
  return rtc.navigator.mediaDevices.getUserMedia(<String, dynamic>{
    'audio': false,
    'video': device != null ? constraints : true,
  });
}