Skip to content

Commit

Permalink
fix broken links, add camera recorder docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jodeleeuw committed Jun 7, 2024
1 parent 3908e51 commit a83590a
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/developers/plugin-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
2 changes: 1 addition & 1 deletion docs/overview/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion docs/overview/prolific.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions docs/plugins/call-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ import callFunction from '@jspsych/plugin-call-function';
}
}
```
<a name="async-example"></a>

???+ example "Async function call: simulate waiting for an event to finish"
=== "Code"
Expand Down
2 changes: 1 addition & 1 deletion docs/plugins/virtual-chinrest.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)._

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/jspsych-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
61 changes: 61 additions & 0 deletions docs/reference/jspsych-pluginAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a83590a

Please sign in to comment.