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 committed by KristinDiep
parent 6c6495c783
commit 1bf201bd7f
3 changed files with 4 additions and 3 deletions

View File

@ -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({

BIN
examples/sound/tone.mp3 Normal file

Binary file not shown.

View File

@ -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