web icon indicating copy to clipboard operation
web copied to clipboard

The IDL for MediaTrackConstraints seems to be missing properties

Open navaronbracke opened this issue 1 year ago • 0 comments

I'm currently looking into migrating a package to the new package:web interop.

For my use-case I need to use MediaDevices.getUserMedia(constraints).

I can create a MediaStreamConstraints with booleans for video and audio. But if I want to give it more refined constraints, I end up with a problem.

According to the documentation here: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia I can pass a MediaTrackConstraints dictionary as options.

If an object is specified for a media type, the object is read as a MediaTrackConstraints dictionary.

However, when I want to create such an object in Dart, I can only pass a JSArray, which seems wrong. It does not match the properties listed here: https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints

// web/media_capture_streams.dart
@JS()
@staticInterop
@anonymous
class MediaTrackConstraints implements MediaTrackConstraintSet {
  external factory MediaTrackConstraints({JSArray advanced});
}

extension MediaTrackConstraintsExtension on MediaTrackConstraints {
  external set advanced(JSArray value);
  external JSArray get advanced;
}

Probably a bug in the IDL, but worth mentioning.

navaronbracke avatar Nov 27 '23 17:11 navaronbracke