add width and height options for mirror plugin

This commit is contained in:
Josh de Leeuw 2022-05-31 17:25:28 -04:00
parent cade6b7f9e
commit d699a83f11
2 changed files with 15 additions and 2 deletions

View File

@ -16,7 +16,8 @@
} }
const mirror_camera = { const mirror_camera = {
type: jsPsychMirrorCamera type: jsPsychMirrorCamera,
width: 320,
} }
jsPsych.run([init_camera, mirror_camera]); jsPsych.run([init_camera, mirror_camera]);

View File

@ -8,6 +8,16 @@ const info = <const>{
type: ParameterType.STRING, type: ParameterType.STRING,
default: "Continue", default: "Continue",
}, },
/** Height of the video element */
height: {
type: ParameterType.INT,
default: null,
},
/** Width of the video element */
width: {
type: ParameterType.INT,
default: null,
},
}, },
}; };
@ -33,7 +43,9 @@ class MirrorCameraPlugin implements JsPsychPlugin<Info> {
this.stream = this.jsPsych.pluginAPI.getCameraStream(); this.stream = this.jsPsych.pluginAPI.getCameraStream();
display_element.innerHTML = ` display_element.innerHTML = `
<video autoplay playsinline id="jspsych-mirror-camera-video" style=""></video> <video autoplay playsinline id="jspsych-mirror-camera-video" width="${
trial.width ? trial.width : "auto"
}" height="${trial.height ? trial.height : "auto"}"></video>
<p><button class="jspsych-btn" id="btn-continue">${trial.button_label}</button></p> <p><button class="jspsych-btn" id="btn-continue">${trial.button_label}</button></p>
`; `;