Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/audio-stop-bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@jspsych/plugin-audio-button-response": patch
---

Prevent WebAudio stop error when trials end early by removing ended listeners before stopping playback.
3 changes: 2 additions & 1 deletion contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The following people have contributed to the development of jsPsych by writing c
* Andy Heusser - https://github.com/andrewheusser
* Angus Hughes - https://github.com/awhug
* jade - https://github.com/jadeddelta
* Stephen M. Jerge - https://github.com/stephenmjerge
* Gustavo Juantorena - https://github.com/GEJ1
* Chris Jungerius - https://github.com/cjungerius
* George Kachergis - https://github.com/kachergis
Expand Down Expand Up @@ -72,4 +73,4 @@ The following people have contributed to the development of jsPsych by writing c
* Shaobin Jiang - https://github.com/Shaobin-Jiang
* Haotian Tu - https://github.com/thtTNT
* Joshua Unrau - https://github.com/joshunrau
* Victor Zhang - https://github.com/vzhang03
* Victor Zhang - https://github.com/vzhang03
6 changes: 3 additions & 3 deletions packages/plugin-audio-button-response/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,13 @@ class AudioButtonResponsePlugin implements JsPsychPlugin<Info> {

// method to end trial when it is time
private end_trial = () => {
// stop the audio file if it is playing
this.audio.stop();

// remove end event listeners if they exist
this.audio.removeEventListener("ended", this.end_trial);
this.audio.removeEventListener("ended", this.enable_buttons);

// stop the audio file if it is playing
this.audio.stop();

// gather the data to store for the trial
var trial_data = {
rt: this.response.rt,
Expand Down