diff --git a/examples/jspsych-single-audio.html b/examples/jspsych-single-audio.html index 0f723a94..2dbab083 100644 --- a/examples/jspsych-single-audio.html +++ b/examples/jspsych-single-audio.html @@ -20,10 +20,11 @@ type: 'single-audio', trial_ends_after_audio: true, timeline: [ + {stimulus: 'sound/tone.mp3'}, {stimulus: function() { return 'sound/sound.mp3'; }}, {stimulus: 'sound/hammer.mp3'} ], - prompt: 'press any key to advance' + prompt: 'the trial should advance automatically after sound completes, or press any key to advance' } jsPsych.init({ diff --git a/examples/sound/tone.mp3 b/examples/sound/tone.mp3 new file mode 100644 index 00000000..02034e41 Binary files /dev/null and b/examples/sound/tone.mp3 differ diff --git a/plugins/jspsych-single-audio.js b/plugins/jspsych-single-audio.js index 451e8f0c..fb51049f 100644 --- a/plugins/jspsych-single-audio.js +++ b/plugins/jspsych-single-audio.js @@ -90,7 +90,7 @@ jsPsych.plugins["single-audio"] = (function() { end_trial(); } } else { - audio.addEventListener('end', end_trial); + audio.addEventListener('ended', function(){ end_trial(); }); } } @@ -118,7 +118,7 @@ jsPsych.plugins["single-audio"] = (function() { source.onended = function() { } } else { audio.pause(); - audio.removeEventListener('end', end_trial); + audio.removeEventListener('ended', end_trial); } // kill keyboard listeners