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 headphone-check plugin #146

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

add headphone-check plugin #146

wants to merge 6 commits into from

Conversation

jadeddelta
Copy link
Collaborator

hi all, this PR adds the headphone check plugin, a simple yet customizable way to check if a user is wearing headphones or not. this plugin attempts to recreate the functionality of the original HeadphoneCheck plugin described in the 2017 paper that speaks to its efficacy.

all functionality of the original package has been implemented in the style of jsPsych, with a simple boolean at the end to tell if the participant has passed the check or not. to view this plugin for yourself, be sure to do the usual: cd into the plugin-headphone-check directory, run npm i and npm run build, and run the example in /examples/basic-configuration.html. this'll recreate the original parameters as described in the original HeadphoneCheck plugin.

any reviewers would be greatly appreciated, this is my first plugin after all ;^) but i had a blast making it and i can't wait to see how people will use this!

Copy link
Member

@jodeleeuw jodeleeuw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome! here are some quick initial thoughts

it("should load", async () => {
const { expectFinished, getHTML, getData, displayElement, jsPsych } = await startTimeline([
{
type: jsPsychHeadphoneCheck,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a quick update here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a dummy test, but I can't for the life of me figure out how to mock the AudioPlayer class...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mocked the AudioPlayer class in jspsych/jsPsych#3179 and some use cases are shown in the commits here jspsych/jsPsych@d296962

packages/plugin-headphone-check/package.json Outdated Show resolved Hide resolved
@jodeleeuw
Copy link
Member

Also, perhaps it is worth looking into whether the audio files can be distributed via the cdn?

Copy link

changeset-bot bot commented Nov 25, 2024

🦋 Changeset detected

Latest commit: 31db640

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@jspsych-contrib/plugin-headphone-check Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jadeddelta
Copy link
Collaborator Author

Also, perhaps it is worth looking into whether the audio files can be distributed via the cdn?

at this point, it would be interesting to look into adding that functionality to the AudioPlayer class itself so that we can standardize (unless i'm mistaken and you can do it via cdn already)

@jodeleeuw
Copy link
Member

Also, perhaps it is worth looking into whether the audio files can be distributed via the cdn?

at this point, it would be interesting to look into adding that functionality to the AudioPlayer class itself so that we can standardize (unless i'm mistaken and you can do it via cdn already)

Wouldn't you still need the audio files themselves to be available? I think I'm missing something.

@jodeleeuw
Copy link
Member

I think we can add the audio files to the files list in the package.json and then they'll be published and accessible?

https://docs.npmjs.com/cli/v10/configuring-npm/package-json#files

@jadeddelta
Copy link
Collaborator Author

Also, perhaps it is worth looking into whether the audio files can be distributed via the cdn?

at this point, it would be interesting to look into adding that functionality to the AudioPlayer class itself so that we can standardize (unless i'm mistaken and you can do it via cdn already)

Wouldn't you still need the audio files themselves to be available? I think I'm missing something.

my understanding of loading media in jsPsych is that you pass a file path in local memory to the trial- so i'm confused how passing in a link to the cdn that contains the file works in this case

@jodeleeuw
Copy link
Member

my understanding of loading media in jsPsych is that you pass a file path in local memory to the trial- so i'm confused how passing in a link to the cdn that contains the file works in this case

No, we're passing a URL. When experiments are hosted online the media files have to be hosted on a server, and so the audio file is loaded from the URL. One issue that we might run into is CORS requests. Loading media from remote URLs may cause issues. Worth investigating...

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

Successfully merging this pull request may close these issues.

2 participants