createCapture() constraints and facingMode

Are there any resources out there that clearly list all the possible constraints you can apply to createCapture()?

All they do is redirect you to this page:
https://w3c.github.io/mediacapture-main/getusermedia.html#media-track-constraints
and leave it at that.

Basically, I want to change the facingMode so that I can use the environment camera and not the user camera, and as far as I can tell, I have to supply a Constraints object in order to do that.

I don’t know if this is necessarily a problem with the constraints, but the lack of clear examples is a little frustrating. This is the only snippet I have to go off of:

function setup() {
  createCanvas(480, 120);
  var constraints = {
    video: {
      mandatory: {
        minWidth: 1280,
        minHeight: 720
      },
      optional: [{ maxFrameRate: 10 }]
    },
    audio: true
  };
  createCapture(constraints, function(stream) {
    console.log(stream);
  });
}

Someone’s had this problem before, right?

EDIT:
Found a solution here:

But the original problem still remains. What does exact mean? Where do I find a general reference for Constraints?

2 Likes

Thanks for sharing the solution :slight_smile:

I think that is worth asking as a follow-on question on the issue that you linked, e.g. “what does exact mean and is it documented anywhere?”