Skip to content

Commit 3f23fe5

Browse files
author
Gali Geller
committed
Added a new option to the plugin
With this option it is now possible to hide the slider while the video is playing
1 parent cf78fb9 commit 3f23fe5

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

docs/plugins/video-slider-response.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ trial_ends_after_video | bool | false | If true, then the trial will end as soon
3131
trial_duration | numeric | null | How long to wait for the subject to make a response before ending the trial in milliseconds. If the subject fails to make a response before this timer is reached, the subject's response will be recorded as null for the trial and the trial will end. If the value of this parameter is null, then the trial will wait for a response indefinitely.
3232
response_ends_trial | boolean | true | If true, then the trial will end whenever the subject makes a response (assuming they make their response before the cutoff specified by the `trial_duration` parameter). If false, then the trial will continue until the value for `trial_duration` is reached. You can set this parameter to `false` to force the subject to view a stimulus for a fixed amount of time, even if they respond before the time is complete.
3333
response_allowed_while_playing | boolean | true | If true, then responses are allowed while the video is playing. If false, then the video must finish playing before the slider is enabled and the trial can end via the next button click. Once the video has played all the way through, the slider is enabled and a response is allowed (including while the video is being re-played via on-screen playback controls).
34+
hide_slider_while_video_plays | boolean | false | If true, the slider will be hidden while the video is playing, and will appear when the video stops.
3435

3536

3637
## Data Generated

packages/plugin-video-slider-response/src/index.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ const info = <const>{
131131
pretty_name: "Response allowed while playing",
132132
default: true,
133133
},
134+
hide_slider_while_video_plays: {
135+
type: ParameterType.BOOL,
136+
pretty_name: "Hide slider while video plays",
137+
default: false,
138+
description: "If true the slider will be hidden while the video plays and it will appear when the video stops"
139+
},
134140
},
135141
};
136142

@@ -274,6 +280,10 @@ class VideoSliderResponsePlugin implements JsPsychPlugin<Info> {
274280
if (trial.trial_ends_after_video) {
275281
end_trial();
276282
} else if (!trial.response_allowed_while_playing) {
283+
if(trial.hide_slider_while_video_plays) {
284+
show_slider();
285+
}
286+
277287
enable_slider();
278288
}
279289
};
@@ -310,6 +320,10 @@ class VideoSliderResponsePlugin implements JsPsychPlugin<Info> {
310320
var currenttime = video_element.currentTime;
311321
if (currenttime >= trial.stop) {
312322
video_element.pause();
323+
if (trial.hide_slider_while_video_plays){
324+
show_slider();
325+
}
326+
313327
if (trial.trial_ends_after_video && !stopped) {
314328
// this is to prevent end_trial from being called twice, because the timeupdate event
315329
// can fire in quick succession
@@ -336,6 +350,11 @@ class VideoSliderResponsePlugin implements JsPsychPlugin<Info> {
336350
.addEventListener("touchstart", enable_button);
337351
}
338352

353+
if (trial.hide_slider_while_video_plays) {
354+
hide_slider();
355+
}
356+
357+
339358
var startTime = performance.now();
340359

341360
// store response
@@ -405,6 +424,14 @@ class VideoSliderResponsePlugin implements JsPsychPlugin<Info> {
405424
}
406425
}
407426

427+
function hide_slider() {
428+
(document.getElementsByClassName("jspsych-video-slider-response-container")[0] as HTMLElement).style.display = "none";
429+
}
430+
431+
function show_slider() {
432+
(document.getElementsByClassName("jspsych-video-slider-response-container")[0] as HTMLElement).style.display = "";
433+
}
434+
408435
// end trial if time limit is set
409436
if (trial.trial_duration !== null) {
410437
this.jsPsych.pluginAPI.setTimeout(end_trial, trial.trial_duration);

0 commit comments

Comments
 (0)