mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
fix broken links, add camera recorder docs
This commit is contained in:
parent
3908e517fc
commit
a83590a85d
@ -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){
|
||||
|
@ -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({
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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)._
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user