/* jspsych-video.js * Josh de Leeuw * * This plugin displays a video. The trial ends when the video finishes. * * documentation: docs.jspsych.org * */ jsPsych.plugins.video = (function() { var plugin = {}; plugin.info = { name: 'video', description: '', parameters: { sources: { type: jsPsych.plugins.parameterType.VIDEO, array: true, default: undefined, no_function: false, description: 'The video file to play.' }, width: { type: jsPsych.plugins.parameterType.INT, default: undefined, no_function: false, description: 'The width of the video in pixels.' }, height: { type: jsPsych.plugins.parameterType.INT, default: undefined, no_function: false, description: '' }, autoplay: { type: jsPsych.plugins.parameterType.BOOL, default: true, no_function: false, description: '' }, controls: { type: jsPsych.plugins.parameterType.BOOL, default: false, no_function: false, description: '' }, prompt: { type: jsPsych.plugins.parameterType.STRING, default: '', no_function: false, description: '' }, start: { type: jsPsych.plugins.parameterType.FLOAT, default: false, no_function: false, description: 'time to start the clip' }, stop: { type: jsPsych.plugins.parameterType.FLOAT, default: false, no_function: false, description: 'time to stop the clip' } } } plugin.trial = function(display_element, trial) { // display stimulus var video_html = '" //show prompt if there is one if (trial.prompt !== "") { video_html += trial.prompt; } display_element.innerHTML = video_html; display_element.querySelector('#jspsych-video-player').onended = function(){ end_trial(); } // function to end trial when it is time var end_trial = function() { // gather the data to store for the trial var trial_data = { stimulus: JSON.stringify(trial.sources) }; // clear the display display_element.innerHTML = ''; // move on to the next trial jsPsych.finishTrial(trial_data); }; }; return plugin; })();