fix bug for html5 audio use in single-audio

This commit is contained in:
Josh de Leeuw 2017-06-09 23:29:16 -04:00
parent 0917379d9e
commit bf80a689d4
3 changed files with 4 additions and 3 deletions

View File

@ -20,10 +20,11 @@
type: 'single-audio', type: 'single-audio',
trial_ends_after_audio: true, trial_ends_after_audio: true,
timeline: [ timeline: [
{stimulus: 'sound/tone.mp3'},
{stimulus: function() { return 'sound/sound.mp3'; }}, {stimulus: function() { return 'sound/sound.mp3'; }},
{stimulus: 'sound/hammer.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({ jsPsych.init({

BIN
examples/sound/tone.mp3 Normal file

Binary file not shown.

View File

@ -90,7 +90,7 @@ jsPsych.plugins["single-audio"] = (function() {
end_trial(); end_trial();
} }
} else { } else {
audio.addEventListener('end', end_trial); audio.addEventListener('ended', function(){ end_trial(); });
} }
} }
@ -118,7 +118,7 @@ jsPsych.plugins["single-audio"] = (function() {
source.onended = function() { } source.onended = function() { }
} else { } else {
audio.pause(); audio.pause();
audio.removeEventListener('end', end_trial); audio.removeEventListener('ended', end_trial);
} }
// kill keyboard listeners // kill keyboard listeners