Description of the problem: As far as I can tell, the audioObject.pause() method does not work on Pavlovia. Here is the error message I get:
The experiment currently uses sound_1.stop(), which works, but the audio restarts on every next sound_1.play() trial. I’d like the audio to pause at the end of a trial, then resume wherever it left off (i.e., for the next trial with sound).
Does anyone know how to get audioObject.pause() working online?
I tinkered with sound_1.seek() but I think .seek() only works with MovieStim. I also tried doing a manual JS translation for making .pause() work online, but I was unsuccessful. I also don’t know JS well enough.
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 random.
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.
Hopefully .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.