Code to replay and stop playing a loop of sound not working when running online in Pavlovia

URL of experiment: Dhatri S Devaraju / CP_story_v1 · GitLab

Description of the problem: I wanted to present a test sound (“soundcheck” routine) in the beginning of the experiment where a pure tone is played in loop called “replay”. The routine should end when space bar is pressed and should continue to play in loop when ‘return’ is pressed. I used a code looking at the examples from the forum as

if ‘space’ in key_resp.keys:
replay.finished = True

in the end routine tab which works fine when running PsychoPy3 offline using builder. But when I tried running it online in Pavlovia, it just repeatedly plays the sound and records the button presses but the code doesn’t seem like working, because the routine or replay do not end when space bar is pressed.
I tried few work arounds but had no luck. I am new to coding and online experiments. Any help is appreciated!
Thank you in Advance!

Found a solution for this. As JS doesn’t consider the name of the trials loop, irrespective of the name of the loop, the JS code should have ‘trials’ in its code. Thus, in the above code, Just selecting both the codes and changing “replay.finished” to “trials.finished” in JS code solved the problem. Now the sound will replay if ‘return’ is pressed and will stop playing and continue to next routine when ‘space’ is pressed. :grinning:

1 Like