Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html-button-response/html-keyboard-response + no response = hitching #3359

Open
anasophiarc opened this issue Jul 25, 2024 · 1 comment
Open

Comments

@anasophiarc
Copy link

Hi,
I am having an issue as I want to use an html response to display a video as well as some text without giving the participant an option to respond (ie. I just want them to watch the video). The issue is that not all of the videos that could possibly be displayed in the trial variable are exactly the same length and so when I set the trial_duration parameter to one fixed value certain clips get cut off/ there is a lot of screen hitching. Does anyone have an idea on a way I can improve upon this/reduce the stutters? Thanks

Here is a snippet of the stimulus function plus some of the other parameters I am currently using:
return

Permanent Bank: ${score.toFixed(2)}

`

}, 
choices: " ", //no choices -> participant just has to watch the outcome unfold 
response_ends_trial: false, 
trial_duration: 2000, //2 seconds to watch the outcome of decision `
@Shaobin-Jiang
Copy link
Contributor

One way of doing it would be to not set trial_duration at all, but to listen to the ended event of the video element yourself and end the trial manually then. Here is my way of doing it:

const impossible_key = 'impossible-key';
let trial = {
    type: jsPsychVideoKeyboardResponse,
    stimulus: ['./video.mp4'],
    choices: [impossible_key],
    on_load: function () {
        document.querySelector('video').addEventListener('ended', function () {
            jsPsych.pluginAPI.keyDown(impossible_key);
            jsPsych.pluginAPI.keyUp(impossible_key);
        });
    }
};

I have not used the jsPsych finishTrial method because that would mean a lot of extra work. Instead, I set the choices to a key that nobody could possible press as the key is non-existent. Then, I just have to manually dispatch the key down and key up events when video reaches its end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants