Pausing movie stimuli and collecting response time

OS Win10:
PsychoPy version 2020.2.10
What are you trying to achieve?:

Hi all,
I’m pretty new to Python and Psychopy so I apologize if there is an easy fix that I am missing. I’m trying to achieve the following steps: I want to display a movie that is 5 seconds long (from a list of movies) I want participants to be able to pause the movie by pressing on the space bar, to get feedback for the exact time it took them to press the space bar since the movie began. I need the movie to last 5 seconds long regardless of the participant’s response, so the response needs to just pause the movie and not stop it.

What did you try to make it work?:
I managed to add the movie component from a list in an excel file. I tried adding a code snippet I found in the forum here, after defining my movie variable to match the code.
this is the link for the discussion:

this is the code I’ve added. I tried leaving it as is just to see what happens and also changing it to a version more relevant to my needs.

at the beginning of the experiment:
from psychopy.constants import (PLAYING, PAUSED)

at the beginning of the routine:
mov = movie_ori

(the original code from the post)

for key in event.getKeys():
if key in [‘escape’, ‘q’]:
elif key in [‘p’, ]:
# To pause the movie while it is playing…
if mov.status == PLAYING:
elif mov.status == PAUSED:
# To /unpause/ the movie if pause has been called…

(my adjusted version)

for key in event.getKeys():
if key in [‘space’]:

(also tried)
for key in event.getKeys():
if key in [‘space’, ]:

I’ve also tried to change the "elif key in the original code to ‘space’ and to leave it as ‘p’ just to make sure it works, but unfortunately, as I will elaborate both the original and the ‘space’ version I’ve tried in the original code and my adjusted version doesn’t work.

What specifically went wrong when you tried that?:

Unfortunately, while the movie plays it doesn’t pause the movie but rather stops the entire experiment after the movie ends and I get this error:
Alert 4210:JavaScript Syntax Error in ‘Begin JS Experiment’ tab. See ‘Line 1: Unexpected token’ in the ‘Begin JS Experiment’ tab.
For further info see

When I take the beginning of the experiment part out (psychopy.constants import (PLAYING, PAUSED) I get this error:
AttributeError: ‘str’ object has no attribute ‘status’

Also I’m not sure how to time of the exact pausing moment.