Replies: 10 comments
-
Yes, it's definitely something I'd like to add. I wrote a plugin for displaying video for an experiment that I ran about a year ago, but I didn't include it in the library because it was a bit too tailored for that experiment. What kinds of interaction would be needed? Would the plugin simply play a video, without collecting any feedback or interaction from the subject? |
Beta Was this translation helpful? Give feedback.
-
I was thinking about an experiment where participants have to passively watch a series of video clips of predetermined length and participants might need to respond to some questions after each clip. So on a given trial (i.e. a clip), participants could initiate the play but are unable to interact with the clip until the clip runs its course. |
Beta Was this translation helpful? Give feedback.
-
Such a plugin could also be useful when an experimenter wants to deliver task instruction in the format of video (e.g. a screencast of what participants need to do in the coming task) |
Beta Was this translation helpful? Give feedback.
-
Hello, I was wondering was the above request added into jspysch? I am looking to conduct where people see some videos and give their ratings on them, and not sure exactly which plugin to use for that. Thanks! |
Beta Was this translation helpful? Give feedback.
-
If you want to just play a video file and then collect a rating, you can use the single-stim plugin and the video element: var trial = {
type: 'single-stim',
stimulus: '<video autoplay><source src="myvideo.mp4" type="video/mp4"></video>',
prompt: 'Press Y if the video has a gorilla in it, press N otherwise.',
choices: ['y','n'],
is_html: true
} |
Beta Was this translation helpful? Give feedback.
-
Thanks so much for your quick reply! I have actually tried this, but the video doesn't show up, I keep getting the error - Failed to load resource: net::ERR_FILE_NOT_FOUND. I have double checked and the path of the source video is entered correctly. Any ideas on the same? Btw, when I run a simply html file by using the video element, the video does load and play, only with jspsych integration, this element not found occurs. Thanks so much again! |
Beta Was this translation helpful? Give feedback.
-
Here is a short example. It works for me on Google Chrome. <!doctype html>
<html>
<head>
<title>Experiment</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="jspsych-5.0.3/jspsych.js"></script>
<script src="jspsych-5.0.3/plugins/jspsych-single-stim.js"></script>
<link href="jspsych-5.0.3/css/jspsych.css" rel="stylesheet"></link>
</head>
<body>
<div id="jspsych-target"></div>
</body>
<script>
var timeline = [{
type: 'single-stim',
stimulus: '<video autoplay class="block-center"><source src="mov/traffic.mp4" type="video/mp4"></video>',
prompt: '<p class="center-content">Press x to continue</p>',
choices: ['x'],
is_html: true
}];
jsPsych.init({
display_element: $('#jspsych-target'),
timeline: timeline
});
</script>
</html> |
Beta Was this translation helpful? Give feedback.
-
Awesome, that worked. I figured out the problem also, it was a stupid typo from my end. Thanks so much for your help - really appreciated! :) |
Beta Was this translation helpful? Give feedback.
-
I put together a simple video playing plugin for an experiment I'm running right now. I'll expand this to a full plugin in the future. /**
* jspsych-video
* Josh de Leeuw
*
* plugin for playing a video
*
* documentation: docs.jspsych.org
*
**/
jsPsych.plugins["video"] = (function() {
var plugin = {};
//jsPsych.pluginAPI.registerPreload('single-stim', 'stimulus', 'image');
plugin.trial = function(display_element, trial) {
// if any trial variables are functions
// this evaluates the function and replaces
// it with the output of the function
trial = jsPsych.pluginAPI.evaluateFunctionParameters(trial);
// set default values for the parameters
trial.prompt = trial.prompt || "";
// this array holds handlers from setTimeout calls
// that need to be cleared if the trial ends early
var setTimeoutHandlers = [];
// display stimulus
var video_html = '<video id="jspsych-video-player" width="'+trial.width+'" height="'+trial.height+'" '
if(trial.autoplay){
video_html += "autoplay "
}
if(trial.controls){
video_html +="controls "
}
video_html+=">"
for(var i=0; i<trial.sources.length; i++){
var s = trial.sources[i];
var type = s.substr(s.lastIndexOf('.') + 1);
type = type.toLowerCase();
video_html+='<source src="'+s+'" type="video/'+type+'">';
}
video_html +="</video>"
display_element.append(video_html);
document.getElementById('jspsych-video-player').onended = function(){
end_trial();
}
//show prompt if there is one
if (trial.prompt !== "") {
display_element.append(trial.prompt);
}
// 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)
};
//jsPsych.data.write(trial_data);
// clear the display
display_element.html('');
// move on to the next trial
jsPsych.finishTrial(trial_data);
};
};
return plugin;
})(); |
Beta Was this translation helpful? Give feedback.
-
There is now a basic video plugin in the repository, and it will be included in the next release. |
Beta Was this translation helpful? Give feedback.
-
Would it be possible to add a plugin for playing video content?
Beta Was this translation helpful? Give feedback.
All reactions