add width and height options to give some control to file size generated by recording

This commit is contained in:
Josh de Leeuw 2022-05-31 17:48:01 -04:00
parent d699a83f11
commit 9488386a48

View File

@ -13,6 +13,14 @@ const info = <const>{
type: ParameterType.STRING,
default: "Use this camera",
},
width: {
type: ParameterType.INT,
default: null,
},
height: {
type: ParameterType.INT,
default: null,
},
},
};
@ -53,7 +61,16 @@ class InitializeCameraPlugin implements JsPsychPlugin<Info> {
const camera_id = await this.waitForSelection(display_element);
const stream = await navigator.mediaDevices.getUserMedia({ video: { deviceId: camera_id } });
const constraints: any = { video: { deviceId: camera_id } };
if (trial.width) {
constraints.video.width = trial.width;
}
if (trial.height) {
constraints.video.height = trial.height;
}
const stream = await navigator.mediaDevices.getUserMedia(constraints);
this.jsPsych.pluginAPI.initializeCameraRecorder(stream);