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

Add optional callback params to record-video extension (for data handling) #3149

Open
3 tasks
becky-gilbert opened this issue Oct 6, 2023 · 0 comments
Open
3 tasks
Labels
lookit Assigned or related to jsPsych-Lookit integration plugin-modification

Comments

@becky-gilbert
Copy link
Collaborator

becky-gilbert commented Oct 6, 2023

The record-video extension saves the data as a base64 string in the jsPsych, and there doesn't seem to be a way to intercept the video blob data before that point. Base64 strings are a useful way of storing non-text data as strings so that it is available to researchers via the jsPsych data, but it's also non-ideal in many cases (for instance because video recordings can quickly generate a huge amount of data).

It would be really useful if the record-video extension provided some optional function callback parameters that would get called during specific extension events (initialization, on_start, on_finish, etc.) and, when video data is available, receive it as an argument. This would allow researchers to send the video .webm files directly to a server.

If these parameters made available at the extension initialization, then it could look something like this:

const start_custom_upload = () => {
  // set up upload
};

const finish_custom_upload = (videoBlob) => {
  // handle data
};


let jsPsych = initJsPsych({
  extensions: [
    {
        type: jsPsychExtensionRecordVideo, 
        params: {
            on_start: start_custom_upload, 
            on_finish: finish_custom_upload
        }
    }
  ]
});

For naming these extension parameters, it might make sense to use the extension event names (on_start etc.) and/or the media recorder API event names (ondataavailable, etc.).

Remember to add the following in the PR:

  • changelog file
  • change to docs (in docs/extensions/record-video.md)
  • minimal example (on docs page and/or in examples folder)

cc @okaycj

@becky-gilbert becky-gilbert added plugin-modification lookit Assigned or related to jsPsych-Lookit integration labels Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lookit Assigned or related to jsPsych-Lookit integration plugin-modification
Projects
None yet
Development

No branches or pull requests

1 participant