Session Recording

You might prefer to record across multiple trials in a study session. This can be done by using trials created with the start and stop recording plugins. This gives a bit of flexibility over which of the study trials are recorded.

When to use session recording

Sesssion recording should NOT occur simultaneously with trial recording, or with any plugins that already use the webcam (e.g. video config, video consent).

To record a set of trials, add a 'start' trial in your jsPsych experiment timeline right before you'd like to start recording, and add a 'stop' trial at the point in your timeline when you'd like to stop recording.

Don't forget a video config trial!

You MUST have a video config trial in your experiment timeline before doing any session recording.

Start Recording Plugin

The plugin to start session recording is called chsRecord.StartRecordPlugin.

const startRec = { type: chsRecord.StartRecordPlugin };

Parameters

wait_for_connection_message [null or HTML string | null ]

This parameter determines what content should be displayed while the session recording is initializing. If null (the default), then the message 'establishing video connection, please wait' (or appropriate translation based on locale) will be displayed. Otherwise this parameter can be set to a custom string and can contain HTML markup. If you want to embed images/video/audio in this HTML string, be sure to preload the media files with the preload plugin and manual preloading. Use a blank string ("") for no message/content. If a value is provided then the locale parameter will be ignored.

Stop Recording Plugin

The plugin to stop session recording is called chsRecord.StopRecordPlugin.

const stopRec = { type: chsRecord.StopRecordPlugin };

When the trial starts, by default, this plugin will display "uploading video, please wait...", or the appropriate translation based on the locale parameter. This message can be customized using the wait_for_upload_message parameter, which is the HTML-formatted string to be displayed while the session recording is uploading.

const stopRec = {
  type: chsRecord.StopRecordPlugin,
  wait_for_upload_message:
    "<p style='color:red;'>Please wait while we upload your video.</p>",
};

Parameters

wait_for_upload_message [null or HTML string | null ]

This parameter determines what content should be displayed while the session recording is uploading. If null (the default), then the message 'uploading video, please wait...' (or appropriate translation based on locale) will be displayed. Otherwise this parameter can be set to a custom string and can contain HTML markup. If you want to embed images/video/audio in this HTML string, be sure to preload the media files with the preload plugin and manual preloading. Use a blank string ("") for no message/content. If a value is provided then the locale parameter will be ignored.

max_upload_seconds [ Integer | 10 ]

Maximum duration (in seconds) to wait for the session recording to finish uploading before continuing with the experiment. If the maximum upload duration is reached and the upload has not finished, then the experiment will move on and the session recording upload will continue in the background.

Examples

Basic usage

First, make sure that you've added a video config trial to your experiment timeline. Then, create your start and stop recording trials:

const startRec = { type: chsRecord.StartRecordPlugin };
const stopRec = { type: chsRecord.StopRecordPlugin };

Next, create the trials that you would like to be recorded.

const morning = { type: jsPsychHtmlKeyboardResponse, stimulus: "Good morning!" };
const evening = { type: jsPsychHtmlKeyboardResponse stimulus: "Good evening!" };
const night = { type: jsPsychHtmlKeyboardResponse, stimulus: "Good night!" };

Lastly, add these trials to the timeline. Again, the video configuration trial must come before any other recording trials.

jsPsych.run([videoConfig, startRec, morning, evening, night, stopRec]);

It's possible to record only some of the trials. This can be done by moving the stop or start recording trials within the timeline.

jsPsych.run([videoConfig, startRec, morning, evening, stopRec, night]);

You can also create more than one session recording:

jsPsych.run([
  videoConfig,
  startRec,
  morning,
  stopRec,
  evening,
  startRec,
  night,
  stopRec,
]);

Setting parameters

By default, the start session recording plugin will display "establishing video connection, please wait" while establishing the connection to our video storage, and the stop session recording plugin will display "uploading video, please wait..." while the session recording is uploading. You can set the locale parameter value to translate these messages to another language. For example, the trial below will display the Brazilian Portuguese translation of these messages. If the locale string does not match any of the translation codes that we support, then the message will be displayed in English.

const startpRec = {
  type: type: chsRecord.StartRecordPlugin,
  locale: "pt-br",
};
const stopRec = {
  type: chsRecord.StopRecordPlugin,
  locale: "pt-br",
};

You can also set custom content to be displayed at the start of the session recording, while it is initializing, and/or at the end, when the file is uploading. The value must be a string. It can include HTML-formatted content, which means that you can embed audio, video, images etc. (be sure to preload any media files!).

const startpRec = {
  type: type: chsRecord.StartRecordPlugin,
  wait_for_connection_message: "<p style='color:green;>Please wait...</p>"
};
const stopRec = {
  type: chsRecord.StopRecordPlugin,
  wait_for_upload_message: "<p style='color:red;'>Hang on a sec!</p>",
};

By default, the stop session recording plugin will wait up to 10 seconds for the session recording to finish uploading before moving on with the experiment. If the upload does not finish in that time, it will continue to upload in the background. You can adjust this duration with the max_upload_seconds parameter. You may want to increase this duration if, for example, your experiment creates a very long session recording, or you expect that some participants may have slow/unreliable internet connections. This example increases the maximum upload duration from 10 to 20 seconds:

const stopRec = {
  type: chsRecord.StopRecordPlugin,
  max_upload_seconds: 20,
};