Anyway, while developing I noticed an issue on Windows where if you use MovieStim3 stimuli components, you might get issues with keyboard input. That is, keyboard input isn’t sent to the experiment runner as expected, meaning the experiment might not respond to input at all, or input might be sent to both the experiment runner, and whatever other window (eg the code editor) was already open. Here’s an example snippet which produces the error.
from psychopy import visual, core from psychopy.hardware import keyboard win = visual.Window( size=(1024, 768), fullscr=True, screen=0, winType='pyglet', allowGUI=False, allowStencil=False, monitor='testMonitor', color=[0,0,0], colorSpace='rgb', blendMode='avg', useFBO=True, units='height') key_resp = keyboard.Keyboard() text = visual.TextStim(win=win, name='text', text='Waiting for space signal', font='Open Sans', pos=(0, 0), height=0.1, wrapWidth=None, ori=0.0, color='white', colorSpace='rgb', opacity=None, languageStyle='LTR', depth=-1.0); movie = visual.MovieStim3( win, "example-movie-file.mp4", pos=(0, 0), size=win.size ) continueRoutine = True while continueRoutine: keys = key_resp.getKeys(keyList=['space'], waitRelease=False) continueRoutine = not bool(keys) text.draw() win.flip() win.close() core.quit()
Note that it doesn’t matter if one attempts to show the movie or not, just generating the MovieStim3 instance is enough to produce the bug, at least on my setup.
A quick fix for at least some of the issues is that one can add
from moviepy.config import get_setting at the top of one’s script. This ensures that Windows ‘focuses’ on the task as expected, again, at least on my setup.
Anyone interested can read in more detail about the issue here:
I’m using Windows 10 Pro, Version 20H2, ‘OS build 19042.928’. But as can be read in the Issue above, it seems like this problem has been around for a while.
As it’s unclear whether the problems stem from PsychoPy’s interaction with moviepy, or moviepy itself, I won’t open an issue on GitHub. I just wanted to make the information more accessible to others struggling with this, and increase the odds that someone more knowledgeable finds a proper solution.