Preloading set of images per trial #724
-
Hi hi, I am setting up an experiment in which I want to show a set of 20 images for 100 ms each - the images are different every trial. I am using the jspsych-animation plugin which works like a charm but sometimes the server is too slow and it shows an image-pictogram instead of one of the images. I know I could preload all images at the start of the experiment with the jspsych-init function but in my case that would be way too many. Is there a way to preload a set of images prior to every trial (e.g. in the ITI) and then remove them again? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Before a trial with images, or a block of trials, you can use the call-function plugin to preload the images. I'm using getDisplayElement() and pluginAPI.preloadImages() var images = ["image1.png", "image2.png"]
var trial = {
type: "call-function",
async: true,
func: function(done) {
jsPsych.getDisplayElement().innerHTML = '<p>Loading... Please wait.</p>'
jsPsych.pluginAPI.preloadImages(images, function() {
done({ preload: "success" });
})
}
}; |
Beta Was this translation helpful? Give feedback.
Before a trial with images, or a block of trials, you can use the call-function plugin to preload the images. I'm using getDisplayElement() and pluginAPI.preloadImages()