video_keyboard_response errors for simple priming experiment #1693
-
Hi there - getting the following errors: jspsych.js:2234 Invalid media_type parameter for jsPsych.pluginAPI.registerPreload. Please check the plugin file. Code is below: <!doctype html>
<html lang="en">
<head>
<title>Effect of Frame of Reference on Biological Motion [jsPsych]</title>
<meta charset="UTF-8">
<script type="text/javascript" src="jspsych-6.0.0/jspsych.js"></script>
<link href="css/jspsych.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="plugins/jspsych-html-keyboard-response.js"></script>
<script type="text/javascript" src="plugins/jspsych-image-keyboard-response.js"></script>
<script type="text/javascript" src="plugins/jspsych-video-keyboard-response.js"></script>
<script type="text/javascript" src="lib/vendors/jquery-2.2.0.min.js"></script>
<script type="text/javascript" src="lib/jspsych-pavlovia-2020.2.js"></script>
</head>
<body>
<script type='text/javascript'>
/* create timeline */
var timeline = [];
/* init connection with pavlovia.org */
var pavlovia_init = {
type: "pavlovia",
command: "init"
};
timeline.push(pavlovia_init);
/* define welcome message trial */
var welcome = {
type: "html-keyboard-response",
stimulus: "Welcome to the experiment. Press any key to begin."
};
timeline.push(welcome);
/* define instructions trial */
var instructions = {
type: "html-keyboard-response",
stimulus: "<p>In this experiment, a silhouette of the ground " +
"will appear on the top or bottom of the screen</p>" +
"<p>This will be followed by a moving person animated as several moving " +
"dots. This can be upright or inverted</p>" +
"<p>If animation if facing left then press F " +
"as fast as you can.</p>" +
"<p>If animation if facing right then press J " +
"as fast as you can.</p>" +
"<p>Press any key to begin.</p>",
post_trial_gap: 2000
};
timeline.push(instructions);
var prime_fixation_test = {
timeline: [
{
type: 'image-keyboard-response',
stimulus: jsPsych.timelineVariable('prime') ,
choices: jsPsych.NO_KEYS,
trial_duration: 1000,
data: jsPsych.timelineVariable('data'),
},
{
type: 'html-keyboard-response',
stimulus: '+',
choices: jsPsych.NO_KEYS,
trial_duration: 500
},
{
type: 'video-keyboard-response',
stimulus: jsPsych.timelineVariable('test'),
choices: ['f', 'j'],
autoplay: true,
data: jsPsych.timelineVariable('data'),
on_finish: function (data) {
data.correct = data.key_press === jsPsych.pluginAPI.convertKeyCharacterToKeyCode(data.correct_response);
}}
],
timeline_variables: [
{ test: "stimuli/Walk-90L-upright.mp4", prime: "stimuli/Grass_Inverted.jpg"},
{ test: "stimuli/Walk-90L-upright.mp4", prime: "stimuli/Grass_Upright.jpg"},
{ test: "stimuli/Walk-90L-inverted.mp4", prime: "stimuli/Grass_Inverted.jpg"},
{ test: "stimuli/Walk-90L-inverted.mp4", prime: "stimuli/Grass_Upright.jpg"},
{ test: "stimuli/Walk-90R-upright.mp4", prime: "stimuli/Grass_Inverted.jpg"},
{ test: "stimuli/Walk-90R-upright.mp4", prime: "stimuli/Grass_Upright.jpg"},
{ test: "stimuli/Walk-90R-inverted.mp4", prime: "stimuli/Grass_Inverted.jpg" },
{ test: "stimuli/Walk-90R-inverted.mp4", prime: "stimuli/Grass_Upright.jpg" },
],
repetitions: 1,
randomize_order: true,
};
timeline.push(prime_fixation_test);
/* define debrief */
```
var debrief_block = {
type: "html-keyboard-response",
stimulus: function () {
var trials = jsPsych.data.get().filter({ test_part: 'test' });
var correct_trials = trials.filter({ correct: true });
var accuracy = Math.round(correct_trials.count() / trials.count() * 100);
var rt = Math.round(correct_trials.select('rt').mean());
return "<p>You responded correctly on " + accuracy + "% of the trials.</p>" +
"<p>Your average response time was " + rt + "ms.</p>" +
"<p>Press any key to complete the experiment. Thank you!</p>";
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
I'm not sure, but it looks like maybe the plugin file and jspsych.js file are from different releases. Is that possible? If so, you could download one of the jsPsych releases again, point your script sources at those files, and see if that fixes the problem. |
Beta Was this translation helpful? Give feedback.
-
Found a solution - see below. The plugin required the stimuli in an array. Just add brackets to the example timeline example in the documentation timeline_variables: [ |
Beta Was this translation helpful? Give feedback.
Found a solution - see below. The plugin required the stimuli in an array. Just add brackets to the example timeline example in the documentation
timeline_variables: [
{ test: ["stimuli/Walk-90L-upright.mp4"], prime: "stimuli/Grass_Inverted.jpg"},
{ test: ["stimuli/Walk-90L-upright.mp4"], prime: "stimuli/Grass_Upright.jpg"},
{ test: "stimuli/Walk-90L-inverted.mp4", prime: "stimuli/Grass_Inverted.jpg"},
{ test: "stimuli/Walk-90L-inverted.mp4", prime: "stimuli/Grass_Upright.jpg"},
{ test: "stimuli/Walk-90R-upright.mp4", prime: "stimuli/Grass_Inverted.jpg"},
{ test: "stimuli/Walk-90R-upright.mp4", prime: "stimuli/Grass_Upright.jpg"},
{ test: "stimuli/Walk-90R-inverted.mp4", prime: "stimuli/G…