Skip to content

Commit

Permalink
delete functions removed in v8
Browse files Browse the repository at this point in the history
  • Loading branch information
jadeddelta committed Nov 20, 2024
1 parent e5836b7 commit 6470d40
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 157 deletions.
63 changes: 3 additions & 60 deletions docs/reference/jspsych-pluginAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ Returns a Promise that resolves to an instance of an AudioPlayer class that hold

#### Description

Gets an AudioPlayer class instance which has methods that can be used to play or stop audio that can be played with the WebAudio API or an audio object that can be played as HTML5 Audio.
Gets an AudioPlayer class instance which has methods that can be used to play or stop audio that can be played with the WebAudio API or an audio object that can be played as HTML5 Audio. By default, jsPsych uses the WebAudio API to play audio in the browser, so if you want to use HTML5 Audio, be sure to put `use_webaudio: false` in the `initJsPsych` object.

It is strongly recommended that you preload audio files before calling this method. This method will load the files if they are not preloaded, but this may result in delays during the experiment as audio is downloaded.

Expand Down Expand Up @@ -384,63 +384,6 @@ See the `audio-keyboard-response` plugin for an example in a fuller context.

## Other Media

### getAudioBuffer

```javascript
jsPsych.pluginAPI.getAudioBuffer(filepath)
```

#### Parameters

Parameter | Type | Description
----------|------|------------
filepath | string | The path to the audio file that was preloaded.

#### Return value

Returns a Promise that resolves when the audio file loads. Success handler's parameter will be the audio buffer. If the experiment is running using the WebAudio API it will be an AudioBuffer object. Otherwise, it will be an HTML5 Audio object. The failure handler's parameter is the error generated by `preloadAudio`.

#### Description

Gets an AudioBuffer that can be played with the WebAudio API or an Audio object that can be played with HTML5 Audio.

It is strongly recommended that you preload audio files before calling this method. This method will load the files if they are not preloaded, but this may result in delays during the experiment as audio is downloaded.

#### Examples

##### HTML 5 Audio

```javascript
jsPsych.pluginAPI.getAudioBuffer('my-sound.mp3')
.then(function(audio){
audio.play();
})
.catch(function(err){
console.error('Audio file failed to load')
})
```

##### WebAudio API

```javascript
var context = jsPsych.pluginAPI.audioContext();

jsPsych.pluginAPI.getAudioBuffer('my-sound.mp3')
.then(function(buffer){
audio = context.createBufferSource();
audio.buffer = buffer;
audio.connect(context.destination);
audio.start(context.currentTime);
})
.catch(function(err){
console.error('Audio file failed to load')
})
```

See the `audio-keyboard-response` plugin for an example in a fuller context.

---

### getAutoPreloadList

```javascript
Expand Down Expand Up @@ -564,7 +507,7 @@ None.

#### Description

Generates a `MediaRecorder` object from provided `MediaStream` and stores this for access via [getCameraRecorder()](#getcamerarecorder).
Generates a `MediaRecorder` object from provided `MediaStream` and stores this for access via [`getCameraRecorder()`](#getcamerarecorder).

#### Example

Expand Down Expand Up @@ -597,7 +540,7 @@ None.

#### Description

Generates a `MediaRecorder` object from provided `MediaStream` and stores this for access via [getMicrophoneRecorder()](#getmicrophonerecorder).
Generates a `MediaRecorder` object from provided `MediaStream` and stores this for access via [`getMicrophoneRecorder()`](#getmicrophonerecorder).

#### Example

Expand Down
105 changes: 8 additions & 97 deletions docs/reference/jspsych.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,42 +228,6 @@ const memoryTestProcedure = {

```

---
## jsPsych.addNodeToEndOfTimeline

```javascript
jsPsych.addNodeToEndOfTimeline(node_parameters)
```

### Parameters

| Parameter | Type | Description |
| --------------- | -------- | ---------------------------------------- |
| node_parameters | object | An object defining a timeline. It must have, at a minimum, a `timeline` parameter with a valid timeline array as the value for that parameter. |

### Return value

None.

### Description

Adds the timeline to the end of the experiment.

### Example

```javascript
var trial = {
type: jsPsychHtmlKeyboardResponse,
stimulus: 'This is a new trial.'
}

var new_timeline = {
timeline: [trial]
}

jsPsych.addNodeToEndOfTimeline(new_timeline)
```

---
## jsPsych.evaluateTimelineVariable

Expand Down Expand Up @@ -330,13 +294,14 @@ Returns nothing.

### Description

This method tells jsPsych that the current trial is over. It is used in all of the plugins to end the current trial. When the trial ends a few things happen:
This method tells jsPsych that the current trial is over. It is used in all of the plugins to end the current trial. When the trial ends, a few things happen:

* The data is stored using `jsPsych.data.write()`
* The on_finish callback function is executed for the trial
* The on_trial_finish callback function is executed
* The `on_finish` callback function is executed for the trial
* The `on_trial_finish` callback function is executed
* The display element is cleared, and any timeouts that are pending are cleared.
* The progress bar is updated if it is being displayed
* The experiment ends if the trial is the last one (and the on_finish callback function is executed).
* The experiment ends if the trial is the last one (and the `on_finish` callback function is executed).
* The next trial, if one exists, is started.

### Example
Expand All @@ -363,7 +328,7 @@ Returns the object describing the current trial. The object will contain all of

### Description

Get a description of the current trial
Get a description of the current trial.

### Example

Expand Down Expand Up @@ -467,31 +432,6 @@ alert('You have completed approximately '+progress.percent_complete+'% of the ex
```


---
## jsPsych.getProgressBarCompleted

```javascript
jsPsych.getProgressBarCompleted()
```

### Parameters

None.

### Return value

Returns a value between 0 and 1 representing how full the progress bar currently is.

### Description

Used to get the current value of the progress bar. Works for automated and manual control.

### Example

```javascript
var progress_bar_amount = jsPsych.getProgressBarCompleted();
```

---

## jsPsych.getStartTime
Expand Down Expand Up @@ -570,9 +510,9 @@ Pauses the experiment. The experiment will finish the current trial, but will no
var trial = {
type: jsPsychHtmlKeyboardResponse,
stimulus: 'Press p to take a 30 second break. Otherwise, press c to continue immediately.',
choices: ['p','c'],
choices: ['p', 'c'],
on_finish: function(data){
if(jsPsych.pluginAPI.compareKeys(data.response, "p")) {
if (jsPsych.pluginAPI.compareKeys(data.response, "p")) {
jsPsych.pauseExperiment();
setTimeout(jsPsych.resumeExperiment, 30000);
}
Expand Down Expand Up @@ -648,35 +588,6 @@ jsPsych.run(timeline);

---

## jsPsych.setProgressBar

```javascript
jsPsych.setProgressBar(value)
```

### Parameters

| Parameter | Type | Description |
| --------- | ------- | ---------------------------------------- |
| value | numeric | Proprotion (between 0 and 1) to fill the progress bar. |


### Return value

None.

### Description

Set the progress bar to a custom amount. Proportion must be between 0 and 1. Values larger than 1 are treated as 1.

### Example

```javascript
jsPsych.setProgressBar(0.85);
```

---

## jsPsych.timelineVariable

```javascript
Expand Down

0 comments on commit 6470d40

Please sign in to comment.