Preloading audio samples using timeline

41 views
Skip to first unread message

Georgios Diapoulis

unread,
Jul 29, 2020, 6:10:40 PM7/29/20
to Online Experiments
Hi,

that audio stimuli should be preloaded manually 

Does the following looks correct?  It doesn't work for me.


<!DOCTYPE html>
<html>
 <head>
   <script src="jspsych/jspsych.js"></script>
   <script src="jspsych/plugins/jspsych-html-keyboard-response.js"></script>
   <script src="jspsych/plugins/jspsych-audio-keyboard-response.js"></script>
   <link href="jspsych/css/jspsych.css" rel="stylesheet">
 </head>
 <body></body>
 <script>
   var welcome_trial = {
type: 'html-keyboard-response',
stimulus: 'Welcome to my experiment.'
   }

   var audio_trial = {
type: 'audio-keyboard-response',
stimulus: function() { return 'jspsych/sound/Harvard_L04_S01_5.wav' },
choices: jsPsych.NO_KEYS,
trial_ends_after_audio: true
   };

   var audio = ['jspsych/sound/Harvard_L04_S01_5.wav'];

   jsPsych.init({
timeline: [welcome_trial, image_button_trial, audio_trial],
preload_audio: audio,
on_finish: function(){
   jsPsych.data.displayData();
}
   })

 </script>
</html>

Best
Georgios

jkhart...@gmail.com

unread,
Jul 30, 2020, 12:24:05 PM7/30/20
to Online Experiments
Please post technical question about jsPsych on the jsPsych forum. They're usually pretty quick to respond there.
Thanks!

Josh

Georgios Diapoulis

unread,
Jul 30, 2020, 1:06:11 PM7/30/20
to Online Experiments
OK, thanks a lot.  

Georgios

Reply all
Reply to author
Forward
0 new messages