toMediaConstraintsMap method

  1. @override
Map<String, dynamic> toMediaConstraintsMap()
override

Implementation

@override
Map<String, dynamic> toMediaConstraintsMap() {
  var constraints = <String, dynamic>{
    ...super.toMediaConstraintsMap(),
    if (deviceId == null)
      'facingMode':
          cameraPosition == CameraPosition.front ? 'user' : 'environment'
  };
  if (deviceId != null) {
    if (kIsWeb) {
      constraints['deviceId'] = deviceId;
    } else {
      constraints['optional'] = [
        {'sourceId': deviceId}
      ];
    }
  }
  if (maxFrameRate != null) {
    constraints['frameRate'] = {'max': maxFrameRate};
  }
  return constraints;
}