jsPsych/examples/jspsych-single-audio.html
2017-06-26 11:46:44 -04:00

42 lines
1.4 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<script src="../jspsych.js"></script>
<script src="../plugins/jspsych-single-audio.js"></script>
<link rel="stylesheet" href="../css/jspsych.css"></link>
</head>
<body><p>If you are seeing this message, then you are probably running this example file offline.
Loading the audio files offline requires running your browser in a special mode.
See <a href="https://stackoverflow.com/questions/4819060/allow-google-chrome-to-use-xmlhttprequest-to-load-a-url-from-a-local-file">this Q&A</a>
for examples of how to get this working with Chrome. Other browsers have similar features that you can find more information on via Google.</p></body>
<script>
/*
this demo will only work if run online or with special permissions enable offline
for chrome, launch the browser from the command-line:
chrome --allow-file-access-from-files
*/
var block_1 = {
type: 'single-audio',
trial_ends_after_audio: true,
timeline: [
{stimulus: 'sound/tone.mp3'},
{stimulus: function() { return 'sound/sound.mp3'; }},
{stimulus: 'sound/hammer.mp3'}
],
prompt: 'the trial should advance automatically after sound completes, or press any key to advance'
}
jsPsych.init({
timeline: [block_1],
preload_audio: ['sound/sound.mp3'],
on_finish: function() {jsPsych.data.displayData();}
});
</script>
</html>