Hello, I am trying to link a keypress to a pause/play function using coding so that it would get recorded with timestamps in the output. I would like that whenever someone presses ‘p’, a movie stimulus then pauses or continues playing related to its current status. Although the pause/play function worked (in a past version of the coding below), the timestamps for those keypress were never recorded in the output files nor the movie statuses. I would like to make it so that the keypresses for p are recorded.
I feel like this coding below is getting me close to what I want, but it has crashed my system. Once I press pause, everything stops advancing and I have to escape.
moviekey is a keyboard component put in through builder and the allowed keys are ‘y’ and ‘p’.
I think that having the ‘p’ key in two places: coding and in a keyboard component is what is messing with system. I don’t know how to exactly fix that so any help would be great!
from psychopy.constants import (PLAYING, PAUSED)
# Check for action keys.....
for key in moviekey.keys:
if key in ['p']:
if mov.status == PLAYING:
print('PAUSING')
polygon.setAutoDraw(True)
mov.pause()
win.flip()
if mov.status == PAUSED:
print('UN-PAUSING')
mov.play()
polygon.setAutoDraw(False)