In case anyone needs this, I’ve figured out a workaround to the
.pasue() issue. I still can’t “pause” sound, but I can get the experiment to at least play different parts of an audio file for multiple trials. One of the issues for me was that I could only play the first 5 seconds of a song on multiple trials (i.e., because
.stop() resets the audio file to the beginning.
- I used GarageBand to clip my ~5 minute audio into 5 second increments.
- I added each .wav file to a
mySounds column in an Excel file.
- I created a trials loop to include the Excel file and set trials to
- I created a Sound Component with time set to 0.0 and duration blank.
- I used a Code Component to end the sound and trial.
Now, instead of only playing the first 5 seconds of the audio file on every trial, a random 5 second .wav file is chosen and played. This isn’t ideal, but fortunately I do not need the audio to play in sequence, from beginning to end. Also, I did try setting the trials loop to
sequential, but it repeatedly selects the first 5 seconds of the audio on each trial.
In sum, I used a conditions file to play different parts of a song on each trial.
.pause() will be added to psychoJS so that we can use code components to play and pause audio for a sequential stream on multiple trials.