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.
1 Like