From a83590a85dda89b99735986606ff8a8234df8d1e Mon Sep 17 00:00:00 2001 From: Josh de Leeuw Date: Thu, 6 Jun 2024 21:34:20 -0400 Subject: [PATCH] fix broken links, add camera recorder docs --- docs/developers/plugin-development.md | 4 +- docs/overview/events.md | 2 +- docs/overview/prolific.md | 2 +- docs/plugins/call-function.md | 1 + docs/plugins/virtual-chinrest.md | 2 +- docs/reference/jspsych-data.md | 2 +- docs/reference/jspsych-pluginAPI.md | 61 +++++++++++++++++++++++++++ 7 files changed, 68 insertions(+), 6 deletions(-) diff --git a/docs/developers/plugin-development.md b/docs/developers/plugin-development.md index ac098be9e5..3fd6c26238 100644 --- a/docs/developers/plugin-development.md +++ b/docs/developers/plugin-development.md @@ -135,9 +135,9 @@ trial(display_element, trial){ ### Responding to keyboard events -While the plugin framework allows you to set up any events that you would like to, including normal handling of `keyup` or `keydown` events, the `jsPsych.pluginAPI` module contains the [`getKeyboardResponse` function](../reference/jspsych-pluginAPI.md#jspsychpluginapigetkeyboardresponse), which implements some additional helpful functionality for key responses in an experiment. +While the plugin framework allows you to set up any events that you would like to, including normal handling of `keyup` or `keydown` events, the `jsPsych.pluginAPI` module contains the [`getKeyboardResponse` function](../reference/jspsych-pluginAPI.md#getkeyboardresponse), which implements some additional helpful functionality for key responses in an experiment. -Here's a basic example. See the [`getKeyboardResponse` docs](../reference/jspsych-pluginAPI.md#jspsychpluginapigetkeyboardresponse) for additional examples. +Here's a basic example. See the [`getKeyboardResponse` docs](../reference/jspsych-pluginAPI.md#getkeyboardresponse) for additional examples. ```js trial(display_element, trial){ diff --git a/docs/overview/events.md b/docs/overview/events.md index fa4fac3720..f113cce7a1 100644 --- a/docs/overview/events.md +++ b/docs/overview/events.md @@ -146,7 +146,7 @@ var procedure = { ## on_trial_finish -The `on_trial_finish` callback can be declared in the `initJsPsych` method. The callback will trigger at the end of every trial in the experiment, after the trial object's [`on_finish`](#onfinishtrial) callback has been run. The callback function will be passed a single argument, containing the data object from the trial. If you want a callback to trigger only for the end of certain trials, use the [`on_finish`](#onfinishtrial) callback on the trial object instead. +The `on_trial_finish` callback can be declared in the `initJsPsych` method. The callback will trigger at the end of every trial in the experiment, after the trial object's [`on_finish`](#on_finish-trial) callback has been run. The callback function will be passed a single argument, containing the data object from the trial. If you want a callback to trigger only for the end of certain trials, use the [`on_finish`](#on_finish-trial) callback on the trial object instead. ```javascript initJsPsych({ diff --git a/docs/overview/prolific.md b/docs/overview/prolific.md index d5fb68c67d..b536ae9643 100644 --- a/docs/overview/prolific.md +++ b/docs/overview/prolific.md @@ -43,7 +43,7 @@ When the experiment is complete, Prolific requires that you send the participant You can accomplish this in a couple different ways. !!! warning - It's important that you've saved all the data from your experiment before the participant returns to Prolific. Make sure that any server communication has completed prior to redirecting the participant. One way to do this is by using the async features of the `call-function` plugin ([example](../plugins/call-function.md#async-function-call)). + It's important that you've saved all the data from your experiment before the participant returns to Prolific. Make sure that any server communication has completed prior to redirecting the participant. One way to do this is by using the async features of the `call-function` plugin ([example](../plugins/call-function.md#async-example)). ### Participant clicks a link diff --git a/docs/plugins/call-function.md b/docs/plugins/call-function.md index 1bf354ea41..f14759f4af 100644 --- a/docs/plugins/call-function.md +++ b/docs/plugins/call-function.md @@ -119,6 +119,7 @@ import callFunction from '@jspsych/plugin-call-function'; } } ``` + ???+ example "Async function call: simulate waiting for an event to finish" === "Code" diff --git a/docs/plugins/virtual-chinrest.md b/docs/plugins/virtual-chinrest.md index 497cb595cf..e65af18db9 100644 --- a/docs/plugins/virtual-chinrest.md +++ b/docs/plugins/virtual-chinrest.md @@ -36,7 +36,7 @@ Parameters can be left unspecified if the default value is acceptable. ## Data Generated -In addition to the [default data collected by all plugins](../overview/plugins.md#datacollectedbyplugins), this plugin collects the following data for each trial. +In addition to the [default data collected by all plugins](../overview/plugins.md#data-collected-by-all-plugins), this plugin collects the following data for each trial. _Note: The deg data are **only** returned if viewing distance is estimated with the blindspot method (px2deg, win_height_deg, win_width_deg, item_width_deg)._ diff --git a/docs/reference/jspsych-data.md b/docs/reference/jspsych-data.md index 2a90ac4204..38fe5e7fa5 100644 --- a/docs/reference/jspsych-data.md +++ b/docs/reference/jspsych-data.md @@ -282,7 +282,7 @@ Returns nothing. ### Description -This method is used by `jsPsych.finishTrial` for writing data. You should probably not use it to add data. Instead use [jsPsych.data.addProperties](#addProperties). +This method is used by `jsPsych.finishTrial` for writing data. You should probably not use it to add data. Instead use [jsPsych.data.addProperties](#jspsychdataaddproperties). ### Example diff --git a/docs/reference/jspsych-pluginAPI.md b/docs/reference/jspsych-pluginAPI.md index 94e061d32a..8670866e9a 100644 --- a/docs/reference/jspsych-pluginAPI.md +++ b/docs/reference/jspsych-pluginAPI.md @@ -326,6 +326,33 @@ jsPsych.pluginAPI.getAutoPreloadList(timeline); --- +### getCameraRecorder + +```javascript +jsPsych.pluginAPI.getCameraRecorder() +``` + +#### Parameters + +None + +#### Return value + +A `MediaRecorder` object connected to the `MediaStream` for the active camera. + +#### Description + +Provides access to the `MediaRecorder` created by [initializeCameraRecorder()](#initializecamerarecorder). +If no camera recorder exists, it returns `null`. + +#### Example + +```javascript +const recorder = jsPsych.pluginAPI.getCameraRecorder(); +``` + +--- + ### getMicrophoneRecorder ```javascript @@ -353,6 +380,40 @@ const recorder = jsPsych.pluginAPI.getMicrophoneRecorder(); --- +### initializeCameraRecorder + +```javascript +jsPsych.pluginAPI.initializeCameraRecorder(stream) +``` + +#### Parameters + +Parameter | Type | Description +----------|------|------------ +stream | `MediaStream` | The `MediaStream` object from an active camera device. +opts | `MediaRecorderOptions` | The `MediaRecorderOptions` for the recorder. See [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/MediaRecorder) for details about these options. + +#### Return value + +None. + +#### Description + +Generates a `MediaRecorder` object from provided `MediaStream` and stores this for access via [getCameraRecorder()](#getcamerarecorder). + +#### Example + +```javascript +const stream = await navigator.mediaDevices.getUserMedia({ + audio: true, + video: { width: 1280, height: 720 }, // request a certain resolution +}); + +jsPsych.pluginAPI.initializeCameraRecorder(stream); +``` + +--- + ### initializeMicrophoneRecorder ```javascript