Black Heart
Black Heart

Reputation: 649

navigator.mediaDevices.getUserMedia Video quality and facing mode constraints

I'm not able to specify video quality and camera facing constraints together. Is there a way to combine the below constraints?

{
  audio: true,
  video: { width: 1280, height: 720 }
}

{ audio: true, video: { facingMode: "user" } }

Upvotes: 2

Views: 2317

Answers (1)

Polaris
Polaris

Reputation: 712

navigator.mediaDevices.getUserMedia({ audio: true, video: getConstraints(1280, 720) });

function getConstraints(videowidth, videoheight) {
    constraints = {
        facingMode: { exact: "environment" },
        width: { min: videowidth, ideal: videowidth, max: videowidth },
        height: { min: videoheight, ideal: videoheight, max: videoheight },
        frameRate: { min: 5, max: 8 }
    };
    return constraints;
}

Upvotes: 2

Related Questions