I have an experiment with 44 trials. I need a video to play and then a response trial to play after that. There are 44 different videos that each need a response trial. I need this also to be randomized.
It will only play the first video “CF19.mp4” and will not play the other videos. I have been workshoping it and have only been trying with 2 videos so far (which you will see in the code). Any advice would be helpful! In the code below I left some things in there that I have tried previously!
<!DOCTYPE html>
<html>
<head>
<title>Point Light Walker Experiment</title>
<script src="https://unpkg.com/[email protected]"></script>
<script src="https://unpkg.com/@jspsych/[email protected]"></script>
<script src="https://unpkg.com/@jspsych/[email protected]"></script>
<script src="https://unpkg.com/@jspsych/[email protected]"></script>
<!-- <script src="../dist/plugin-html-keyboard-response.js"></script>
<script src="jspsych/plugin-video-keyboard-response.js"></script> -->
<link href="https://unpkg.com/[email protected]/css/jspsych.css" rel="stylesheet" type="text/css" />
</head>
<body>
<style>
body {background-color: black; color: white;}
</style>
</body>
<script>
/* initialize jsPsych */
var jsPsych = initJsPsych();
/* create timeline */
var timeline = [];
var preload = {
type: jsPsychPreload,
videos: ['video/CF08.mp4', 'video/CF19.mp4','video/CF22.mp4','video/CF26.mp4','video/CF27.mp4', 'video/CF31.mp4',
'video/CF34.mp4','video/CF36.mp4', 'video/CF37.mp4','video/GA2.mp4', 'video/GA09.mp4', 'video/GA12.mp4',
'video/GA17.mp4','video/GA40.mp4', 'video/GA41.mp4', 'video/JH04.mp4', 'video/JH07.mp4', 'video/JH11.mp4',
'video/JH13.mp4','video/JH31.mp4', 'video/JH37.mp4', 'video/JH41.mp4', 'video/JH42.mp4', 'video/JH44.mp4',
'video/JH45.mp4', 'video/MM01.mp4','video/MM18.mp4','video/MM22.mp4', 'video/MM24.mp4', 'video/MM37.mp4',
'video/MM39.mp4', 'video/MS13.mp4','video/MS18.mp4', 'video/MS23.mp4', 'video/MS25.mp4', 'video/MS30.mp4',
'video/MS36.mp4', 'video/TL05.mp4','video/TL21.mp4', 'video/TL23.mp4', 'video/TL24.mp4', 'video/TL27.mp4',]
};
timeline.push(preload);
var videos = [
[{type: 'mp4', 'src': "video/CF08.mp4"}],
[{type: 'mp4', 'src': "video/CF19.mp4"}],
[{type: 'mp4', 'src': "video/CF22.mp4"}]
];
/* define fixation and test trials */
// var CF08trial = {
// type: jsPsychVideoKeyboardResponse,
// stimulus: jsPsych.timelineVariable('video'),
// response_allowed_while_playing: false,
// trial_ends_after_video:true,
// post_trial_gap: 1000
// };
var stimuli = ["video/CF19.mp4", "video/CF08.mp4"];
var CF08trial = {
type: jsPsychVideoKeyboardResponse,
stimulus: stimuli,
response_allowed_while_playing: false,
trial_ends_after_video:true,
post_trial_gap: 1000
};
var CF08response = {
type: jsPsychHtmlKeyboardResponse,
stimulus: `
<p> 1 = Sad 2 = Happy 3 = Angry 4 = Afraid 5 = Neutral </p>
<div style='width: 1000px;'>
</div>
`,
choices: ['1', '2', '3', '4', '5'],
response_ends_trial:true
};
/* define test procedure */
var test_procedure = {
timeline: [CF08trial, CF08response],
timeline_variables: stimuli
};
timeline.push(test_procedure);
/* start the experiment */
jsPsych.run(timeline);
</script>
</html>`
I have tried watching some videos online and looking on here but I am still unable to get it to work properly
sp2 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.