mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 19:20:55 +00:00
fix #315 docs
This commit is contained in:
parent
45af5158e9
commit
6301cb139d
@ -303,7 +303,9 @@ on_data_update | function | Function to execute every time data is stored using
|
||||
on_interaction_data_update | function | Function to execute every time a new interaction event occurs. Interaction events include clicking on a different window (blur), returning to the experiment window (focus), entering full screen mode (fullscreenenter), and exiting full screen mode (fullscreenexit).
|
||||
exclusions | object | Specifies restrictions on the browser the subject can use to complete the experiment. See list of options below.
|
||||
show_progress_bar | boolean | If true, then [a progress bar](../features/progress-bar.md) is shown at the top of the page.
|
||||
max_load_time | numeric | The maximum number of milliseconds to wait for audio content to preload. If the wait time is exceeded an error message is displayed and the experiment stops. The default value is 60 seconds.
|
||||
preload_audio | array | An array of audio files to preload before starting the experiment.
|
||||
preload_images | array | An array of image files to preload before starting the experiment.
|
||||
max_load_time | numeric | The maximum number of milliseconds to wait for content to preload. If the wait time is exceeded an error message is displayed and the experiment stops. The default value is 60 seconds.
|
||||
fullscreen | boolean | If true, the experiment will run in fullscreen mode. See the [feature page](../features/fullscreen.md) for more details.
|
||||
default_iti | numeric | The default inter-trial interval in ms. The default value if none is specified is 0ms.
|
||||
|
||||
|
@ -23,9 +23,9 @@ jsPsych.init({
|
||||
});
|
||||
```
|
||||
|
||||
If you are using images in your experiment but they are not being passed directly as parameters to the trials, then you may need to manually preload the image files.
|
||||
If you are using images or audio in your experiment but they are not being passed directly as parameters to the trials (e.g., because you are using functions as parameters that return the image or audio), then you may need to manually preload the image files.
|
||||
|
||||
jsPsych has an image preloading function in the core library. For full documentation, see the [API reference page](../core_library/jspsych-pluginAPI.md#jspsychpluginapipreloadimages). The function will load all of the images listed in an array, and then call a function when the loading is complete. Below is a brief example.
|
||||
You can specify an array of image files and an array of audio files for preloading in the `jsPsych.init()` method. These files will load before the experiment starts.
|
||||
|
||||
```javascript
|
||||
// this trial will not preload the images, because the image file is being used
|
||||
@ -36,16 +36,19 @@ var trial = {
|
||||
is_html: true
|
||||
}
|
||||
|
||||
var audio_trial = {
|
||||
type: 'single-audio',
|
||||
stimulus: function() { return 'audio/foo.mp3' }
|
||||
}
|
||||
|
||||
// an array of paths to images that need to be loaded
|
||||
var images = ['img/file1.png'];
|
||||
var audio = ['audio/foo.mp3'];
|
||||
|
||||
jsPsych.pluginAPI.preloadImages(images, function(){ startExperiment(); });
|
||||
|
||||
function startExperiment(){
|
||||
jsPsych.init({
|
||||
timeline: [trial]
|
||||
timeline: [trial],
|
||||
audio_preload: audio,
|
||||
image_preload: images
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
Note: If you are using HTML strings as stimuli, such as in the single-stim plugin, you will see a series of error messages in the JavaScript console about failing to find files. These messages can be ignored.
|
||||
```
|
||||
|
@ -24,14 +24,12 @@
|
||||
prompt: 'press any key to advance'
|
||||
}
|
||||
|
||||
jsPsych.pluginAPI.preloadAudioFiles(['sound/sound.mp3'], start);
|
||||
|
||||
function start(){
|
||||
jsPsych.init({
|
||||
timeline: [block_1],
|
||||
preload_audio: ['sound/sound.mp3']
|
||||
on_finish: function() {jsPsych.data.displayData();}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</html>
|
||||
|
@ -45,15 +45,15 @@
|
||||
repetitions: 2
|
||||
}
|
||||
|
||||
jsPsych.pluginAPI.preloadAudioFiles(['sound/sound.mp3','sound/hammer.mp3'], function() {
|
||||
jsPsych.init({
|
||||
timeline: [node],
|
||||
preload_audio: ['sound/sound.mp3','sound/hammer.mp3'],
|
||||
on_finish: function() {
|
||||
jsPsych.data.displayData();
|
||||
},
|
||||
default_iti: 250
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user