mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 19:20:55 +00:00
fix bug for html5 audio use in single-audio
This commit is contained in:
parent
0917379d9e
commit
bf80a689d4
@ -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
BIN
examples/sound/tone.mp3
Normal file
Binary file not shown.
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user